我在网上找到的这个代码在ABAQUS中运行时创建了一个螺旋。我试图理解它背后的逻辑,或许可以将其定制为我的螺旋尺寸。
我在我理解的代码行之上添加了评论。
#######################
# Imports controls from abaqus
from abaqus import *
from abaqusConstants import *
# Defining helix dimensions
width = 20.0
height = 0.05
origin = (15.0, 0.0)
pitch = 50.0
numTurns = 1.0
# Creating sketch in abaqus under name 'rect' and sheetsize of 200
s = mdb.models['Model-1'].ConstrainedSketch(name='rect', sheetSize=200.0)
# No idea. What does .geometry return?
g = s.geometry
# No idea
s.setPrimaryObject(option=STANDALONE)
# Creating a line from point1 to point2, why not use .Line?
cl = s.ConstructionLine(point1=(0.0, -100.0), point2=(0.0, 100.0))
# No idea as I don't know what is stored in g (adding constraints but where?
s.FixedConstraint(entity=g[2])
s.FixedConstraint(entity=g[cl.id])
# Creating rectangle from point1 to point2
s.rectangle(point1=(origin[0], origin[1]), point2=(origin[0]+width, origin[1]+height))
# Creating Part-1 3D Deformable
p = mdb.models['Model-1'].Part(name='Part-1', dimensionality=THREE_D,
type=DEFORMABLE_BODY)
p = mdb.models['Model-1'].parts['Part-1']
p.BaseSolidRevolve(sketch=s, angle=numTurns*360.0, flipRevolveDirection=OFF,
pitch=pitch, flipPitchDirection=OFF, moveSketchNormalToPath=OFF)
#In above command try changing the following member: moveSketchNormalToPath=ON
s.unsetPrimaryObject()
session.viewports['Viewport: 1'].setValues(displayedObject=p)
有人可以详细说明这背后的逻辑吗?
答案 0 :(得分:1)
此代码创建一个从point1到point2的Construction(!!)行,围绕此行,你的helix将构造:
cl = s.ConstructionLine(point1=(0.0, -100.0), point2=(0.0, 100.0))
此代码围绕构造线旋转草图(矩形),并定义间距和圈数:
p.BaseSolidRevolve(sketch=s, angle=numTurns*360.0, flipRevolveDirection=OFF,
pitch=pitch, flipPitchDirection=OFF, moveSketchNormalToPath=OFF)