- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Some months ago I was excited to read that the Drawings workspace had introduced some new attributes - part name, part number & part description. I had previously been typing these in manually to all of my part drawings - which becomes VERRRRRY tedious.
Unfortunately on a Flat Pattern drawing, the part name and part number are both "Flat Pattern". IMHO - the FP name/description should be the same as the 3D component name/description; they're the same physical thing afterall. I queried Autodesk, and apparently it was a conscious decision.
I decided that I could write a script to change a model's flatpattern objects to have the names/numbers/descriptions mirror the 3D component names/numbers/descriptions.
On the user interface, create sheetmetal component, create the flatpattern, activate the flatpattern and check the properties of the flatpattern.
Part Number: Flat Pattern
Part Name: Flat Pattern
Description:
etc.
It seems The Part Name is read only. However, the Part Number and Description can be changed, and these changes are reflected in the drawings that use these attributes.
So for giggles I started with this code:
for component in components:
for body in component.bRepBodies:
if body.isSheetMetal:
#Indicates if this body represents a sheet metal folded part or not and if a flat pattern can be created.
msg = f'Component \t "{component.name}" has sheet metal body'
futil.log(msg, adsk.core.LogLevels.InfoLogLevel)
if not component.flatPattern:
msg = f'\tNo flat pattern exists'
futil.log(msg, adsk.core.LogLevels.InfoLogLevel)
else:
msg = f'\tFlat pattern name = "{component.flatPattern.name}"'
futil.log(msg, adsk.core.LogLevels.InfoLogLevel)
which produced:
Component "0400-S001 v1" has sheet metal body
Flat pattern name = "FlatPattern1"
Component "No Folds" has sheet metal body
Flat pattern name = "FlatPattern1"
Component "0400-S005-0 v1" has sheet metal body
Flat pattern name = "FlatPattern1"
Huh ? On the UI - the name is "Flat Pattern" - but component.flatPattern.name reveals "FlatPattern1" ?
So where/what is the UI Name/Number/Description ?
If I make a change to the component.flatPattern.name property - the change is accepted, and if I query the object again, I can see my change. However, if I close the model and reopen, the changes are lost.
Ideas ? Thoughts ?
Solved! Go to Solution.