Skip to content

Commit e184654

Browse files
authored
Fix: topology optimization example (#215)
1 parent ef5dc6a commit e184654

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

examples/basic/topology_optimization_cantilever_beam.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,32 +100,19 @@ def display_image(image_name):
100100

101101
ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardMKS
102102

103-
# Store all main tree nodes as variables
104-
105-
GEOM = ExtAPI.DataModel.Project.Model.Geometry
106-
MSH = ExtAPI.DataModel.Project.Model.Mesh
107-
NS_GRP = ExtAPI.DataModel.Project.Model.NamedSelections
108-
CONN_GRP = ExtAPI.DataModel.Project.Model.Connections
109-
MY_TOTAL_VOL = GEOM.Volume.Value
110-
MY_TOTAL_MA = GEOM.Mass.Value
111-
112103
# Get structural analysis and link to topology optimization
113104

114105
TOPO_OPT = ExtAPI.DataModel.Project.Model.AddTopologyOptimizationAnalysis()
115106
TOPO_OPT.TransferDataFrom(STRUCT)
116107

108+
OPT_REG = DataModel.GetObjectsByType(DataModelObjectCategory.OptimizationRegion)[0]
109+
OPT_REG.BoundaryCondition = BoundaryConditionType.AllLoadsAndSupports
110+
OPT_REG.OptimizationType = OptimizationType.TopologyDensity
111+
117112
# sphinx_gallery_start_ignore
118113
assert str(TOPO_OPT.ObjectState) == "NotSolved"
119114
# sphinx_gallery_end_ignore
120115

121-
# Set ``None`` for optimization region boundary condition exclusion region
122-
# Optimization region
123-
124-
OPT_REG = TOPO_OPT.Children[1]
125-
# OPT_REG.BoundaryCondition=BoundaryConditionType.None
126-
# Using ``getattr`` because Python.Net does not support the ``None`` enum
127-
OPT_REG.BoundaryCondition = BoundaryConditionType.AllLoadsAndSupports
128-
129116
# Insert volume response constraint object for topology optimization
130117
# Delete mass response constraint
131118

@@ -135,22 +122,13 @@ def display_image(image_name):
135122
# Add volume response constraint
136123

137124
VOL_CONSTRN = TOPO_OPT.AddVolumeConstraint()
138-
# VOL_CONSTRN.DefineBy=ResponseConstraintDefineBy.Constant
139-
# VOL_CONSTRN.PercentageToRetain=50
140125

141126
# Insert member size manufacturing constraint
142127

143128
MEM_SIZE_MFG_CONSTRN = TOPO_OPT.AddMemberSizeManufacturingConstraint()
144129
MEM_SIZE_MFG_CONSTRN.Minimum = ManuMemberSizeControlledType.Manual
145130
MEM_SIZE_MFG_CONSTRN.MinSize = Quantity("2.4 [m]")
146131

147-
# # Store coordinate system ID for use in symmetry manufacturing constraint
148-
# Coordinate_Systems = DataModel.Project.Model.CoordinateSystems
149-
# coord_sys7 = Coordinate_Systems.Children[7]
150-
151-
# # Insert symmetry manufacturing constraint
152-
# SYMM_MFG_CONSTRN = TOPO_OPT.AddSymmetryManufacturingConstraint()
153-
# SYMM_MFG_CONSTRN.CoordinateSystem = coord_sys7
154132

155133
TOPO_OPT.Activate()
156134
ExtAPI.Graphics.Camera.SetFit()

0 commit comments

Comments
 (0)