2016-09-28 35 views
0

我有在線發現的代碼,在ABAQUS中運行時會創建螺旋。我試圖理解它背後的邏輯,以便可能將其定製爲我的螺旋線的大小。用於ABAQUS創建螺旋的Python代碼

我在代碼行上面添加了註釋,我明白了。

####################### 
# 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

我覺得並不需要有幾件事情,我相信他們只是GUI(草圖模塊)設置。嘗試註釋掉兩個'FixedConstraint'行,然後是ConstructionLine,然後是「g =」。 set/unsetprimaryobject也可以。 – agentp

+0

讓我在早上嘗試一下,回到你身邊。 –

回答

1

此代碼從點1創建一個建設(!)線點2,圍繞這條線的螺旋將建:

cl = s.ConstructionLine(point1=(0.0, -100.0), point2=(0.0, 100.0))

這個代碼圍繞草圖(rectange)周圍的建築符合規定間距和圈數:

p.BaseSolidRevolve(sketch=s, angle=numTurns*360.0, flipRevolveDirection=OFF, pitch=pitch, flipPitchDirection=OFF, moveSketchNormalToPath=OFF)