- Goal
The following script example enables you to create a Construction Line using cylindrical faces and the axis to rotation (parallel to global Y) about those faces. This is essentially an abstraction of a bolt.
- Code
# From a selection of cylindrical faces, create construction line on the cylinder's axis curSel=ExtAPI.SelectionManager.CurrentSelection construction_geometry = Model.ConstructionGeometry if construction_geometry == None: construction_geometry = Model.AddConstructionGeometry() for faceId in curSel.Ids: print faceId face=ExtAPI.DataModel.GeoData.GeoEntityById(faceId) if face.Type != GeoCellTypeEnum.GeoFace: continue; if face.SurfaceType != GeoSurfaceTypeEnum.GeoSurfaceCylinder: continue; mid1=face.Edges[0].Centroid mid2=face.Edges[1].Centroid construction_line = construction_geometry.AddConstructionLine() [global_points_1] = construction_line.CreatePoints([mid1]) [global_points_2] = construction_line.CreatePoints([mid2]) edge_collection = construction_line.CreateStraightLines([global_points_1, global_points_2], [(0, 1)]) with Transaction(): construction_line.AddToGeometry()