Investigating a need to set property value for a design, I initially could only set those that appear in the 'General' window.
From Scripts posted by IDSLK (Stefan), I saw that it is possible to set the 'Part Data' properties - though I was struggling to follow the scripts.
I've taken Stefan's latest script - thanks Stefan ! - and stripped out all but the most basic functionality. This is to help me to understand how things work, so that I can move on to creating my own automations. There are a few things that I don't understand - I'm not sure to what extent some of this may be that the Python use might differ slightly from that in the books I'm studying, which items might be specific to AlibreScript, and which are just stylistic.
My 'hacked' code is attached
Questions to anyone who can help...
1. What is clr ?, and what does the r prior to the path name mean ? ( root maybe ?)
2. Root, Global.Root , TopmostSession - what do these relate to? How does this map to CurrentPart, some other part, etc. in Alibre ? I can use this code to set a value for the file it is in, but I know you can also run code in one AD Part that (say) modifies another Part. I don't see how this ties together .
3. I can see (by trying it) that I can't simply replace 'ThisSession' in the main functional line with CurrentPart - it doesn't work. This is probably just an extension of my lack of understanding at 2.
As you can tell I'm new to Python - though I have coded in other languages previously.
From Scripts posted by IDSLK (Stefan), I saw that it is possible to set the 'Part Data' properties - though I was struggling to follow the scripts.
I've taken Stefan's latest script - thanks Stefan ! - and stripped out all but the most basic functionality. This is to help me to understand how things work, so that I can move on to creating my own automations. There are a few things that I don't understand - I'm not sure to what extent some of this may be that the Python use might differ slightly from that in the books I'm studying, which items might be specific to AlibreScript, and which are just stylistic.
My 'hacked' code is attached
Code:
# initial stuff is about importing the capability to connect to extended properties
import clr
clr.AddReferenceToFileAndPath(r'C:\Program Files\Alibre Design\Program\AlibreX.dll')
from AlibreX import ADExtendedDesignProperty
# I'm not clear quite what this bit does - but it is used below
Root = Global.Root
ThisSession = Root.TopmostSession
#main--------------------
#This next line actually sets the 'extended' property value
ThisSession.DesignProperties.ExtendedDesignProperty(ADExtendedDesignProperty.AD_VENDOR,'Toblerone')
# this example alters Vendor but you can substitute in the above line from any of the full extended property names
# AD_COMMENT
# AD_COST_CENTER
# AD_CREATED_BY
# AD_CREATING_APPLICATION
# AD_CREATED_DATE
# AD_DOCUMENT_NUMBER
# AD_ENG_APPROVAL_DATE
# AD_ENG_APPROVED_BY
# AD_ESTIMATED_COST
# AD_KEYWORDS
# AD_LAST_AUTHOR
# AD_LAST_UPDATE_DATE
# AD_MATERIAL
# AD_MFG_APPROVED_BY
# AD_MFG_APPROVED_DATE
# AD_PRODUCT
# AD_RECEIVED_FROM
# AD_REVISION
# AD_STOCK_SIZE
# AD_SUPPLIER
# AD_TITLE
# AD_VENDOR
# AD_WEBLINK
Questions to anyone who can help...
1. What is clr ?, and what does the r prior to the path name mean ? ( root maybe ?)
2. Root, Global.Root , TopmostSession - what do these relate to? How does this map to CurrentPart, some other part, etc. in Alibre ? I can use this code to set a value for the file it is in, but I know you can also run code in one AD Part that (say) modifies another Part. I don't see how this ties together .
3. I can see (by trying it) that I can't simply replace 'ThisSession' in the main functional line with CurrentPart - it doesn't work. This is probably just an extension of my lack of understanding at 2.
As you can tell I'm new to Python - though I have coded in other languages previously.