CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > ANSYS Meshing & Geometry

[Other] Spaceclaim automatic body generator

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2024, 06:31
Default Spaceclaim automatic body generator
  #1
New Member
 
Join Date: Mar 2024
Posts: 2
Rep Power: 0
Sonenzon is on a distinguished road
Hello,

TL;DR: I wish to write a python script which creates box bodies from their x,y,z dimensions and centroid locations - [Xdim,Ydim,Zdim] and [Xloc,Yloc,Zloc], in relation to a local origin .

I tried to use
BlockBody.Create(Point.Create(MM(0), MM(0), MM(0)), Point.Create(MM(Ydim), MM(Xdim), MM(Zdim))
but it creates the box according to translation and orientation of the global origin

Relocating the box afterwards becomes problematic because the relation, both translation and orientation, between the local and global origin must be calculated. It can be a possible solution but I neither want to do it manually nor know how to do it automatically using scripting

thank you in advance,
Sonenzon
Sonenzon is offline   Reply With Quote

Old   March 19, 2024, 05:47
Default [Solved]
  #2
New Member
 
Join Date: Mar 2024
Posts: 2
Rep Power: 0
Sonenzon is on a distinguished road
In case anyone in the future might find this topic useful

Given the following data:
- Position of centroid [Xpos, Ypos, Zpos]
- Dimensions of a box [Xdim, Ydim, Zdim]
- local cordinate system named 'local_sys'

Code:
# Box Position
Xpos=69.3
Ypos=39.5
Zpos=float(2.94)

# Components Dimensions
Xdim=float(11.09)
Ydim=float(10.61)
Zdim=float(0.6)

#Creating rectengular sketch of the box in the local origin plane "local_sys" and tranlation to the bottom face of the box = Zpos - Zdim/2
# Set sketch plane
result = ViewHelper.SetSketchPlane(Selection.CreateByNames("local_sys"),None)
axis = HandleAxis.Z
distance = MM(Zpos - Zdim/2)
# Create surface
result = ViewHelper.TransformSectionPlaneAlongAxis(axis, distance)
point1 = Point2D.Create(MM(Xpos - Xdim/2),MM(Ypos - Ydim/2))
point2 = Point2D.Create(MM(Xpos + Xdim/2),MM(Ypos - Ydim/2))
point3 = Point2D.Create(MM(Xpos + Xdim/2),MM(Ypos + Ydim/2))
result = SketchRectangle.Create(point1, point2, point3)
mode = InteractionMode.Solid
result = ViewHelper.SetViewMode(mode, None))

# Extruding box according to Zdim
j = GetRootPart().Bodies 
#Selects the newest body added to the design, which the surface of the box that needed to be extruded
selection = FaceSelection.Create(GetRootPart().Bodies[j.Count-1].Faces[0])
options = ExtrudeFaceOptions()
options.ExtrudeType = ExtrudeType.ForceIndependent
result = ExtrudeFaces.Execute(selection, MM(Zdim), options)
Sonenzon is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fluid Domain moving with Rigid body Lloyd Sullivan CFX 3 August 17, 2018 09:58
Ahmed body simulation gives unexpected results in su2 6.0 anas651 SU2 0 March 28, 2018 03:42
[DesignModeler] How to substract the whole body if the body is partial overlap with the tool body funkvps ANSYS Meshing & Geometry 15 August 3, 2017 00:01
how to move a solid body along a clear line m.r_khani FLUENT 0 November 26, 2011 07:04
Pressure wave pattern over body in steadystate? Chebeba CFX 1 March 16, 2008 02:00


All times are GMT -4. The time now is 06:53.