Skip to content

Commit

Permalink
Create Assembly2part.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianDepriester authored Dec 14, 2017
1 parent 2f3d497 commit 7cc1f40
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Abaqus/Assembly2part.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ============================================================================ #
# When importing INP file into Abaqus, cells are considered as sets in the #
# assembly. This script copies the sets from the assembly to the 'Part' #
# section. #
# ============================================================================ #

# Get the current model name and its part name
vps = session.viewports.values()[0]
mdbName=vps.displayedObject.modelName
pk=mdb.models[mdbName].parts.keys()
partName=pk[0]

# Set the new part visible
p1 = mdb.models[mdbName].parts[partName]
session.viewports['Viewport: 1'].setValues(displayedObject=p1)

# Fecth all sets in the assembly
a=mdb.models[mdbName].rootAssembly
sets=a.sets
sets_list=sets.keys()
p = mdb.models[mdbName].parts[partName]

for cellID in sets_list:
set_i=sets[cellID]
if cellID.startswith('CELL'):
IDs=[j.label for j in set_i.elements]
p.SetFromElementLabels(elementLabels=IDs,name=cellID)

0 comments on commit 7cc1f40

Please sign in to comment.