|
[Sponsors] |
March 14, 2024, 06:31 |
Spaceclaim automatic body generator
|
#1 |
New Member
Join Date: Mar 2024
Posts: 2
Rep Power: 0 |
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 |
|
March 19, 2024, 05:47 |
[Solved]
|
#2 |
New Member
Join Date: Mar 2024
Posts: 2
Rep Power: 0 |
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) |
|
|
|
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 |