Is there an example that shows how to create construction geometry line bodies and use them as beam bodies in Mechanical directly?
# Get the Construction Geometry branch under the Model constructionGeometry = Model.ConstructionGeometry # Add a new Construction Line object beamCenterlineSketch = constructionGeometry.AddConstructionLine() # Get available coordinate systems from the Mechanical tree coordinateSystems = DataModel.GetObjectsByType( DataModelObjectCategory.CoordinateSystem ) # Select the coordinate system that defines the sketch plane # Index 0 is usually Global Coordinate System. sketchCoordinateSystem = coordinateSystems[1] # Create a sketch plane based on the selected coordinate system beamSketchPlane = beamCenterlineSketch.CreatePlane(sketchCoordinateSystem) # Retrieve the created plane by ID # Mechanical internally assigns this first plane ID = 1 [beamSketchPlane] = ConstructionLineHelper.GetPlanesById( beamCenterlineSketch, [1] ) # Define the start and end points of the beam centerline # These coordinates are 2D coordinates on the selected plane. beamStartPointCoordinates = (-0.000240159, 8.15163e-05) beamEndPointCoordinates = (0.0179066, -5.54405e-05) # Create the two planar points [beamStartPoint, beamEndPoint] = beamCenterlineSketch.CreatePlanarPoints( beamSketchPlane, [ beamStartPointCoordinates, beamEndPointCoordinates ] ) # Create a straight line between point 0 and point 1 beamLineEdges = beamCenterlineSketch.CreateStraightLines( [beamStartPoint, beamEndPoint], [(0, 1)] ) # Convert the construction line into actual Geometry line body/bodies beamCenterlineSketch.AddToGeometry()
You can use the above snippet to do the same. The newly created line body will be added to the geometry tree.