Hi all, is it possible to copy property set definition with new name and same definitions/attributes ? Is python necessary?
Hi all, now I can copy Property set definition. I used Python and I was inspired by @Paolo_Emilio_Serra1 pset_utils modules.
I don’t understand how to apply property set definition to “Solid3d” objects. I am in “learning by doing” process. Is here anyone who can help? I don’t understand how StringCollection() and SetAppliesToFilter() method works.
Here is code as it is now in my work in progress.
def copy_ps_definitions(propertySetDefinitionName):
"""Creates a copy of property set definition
:param propertySetDefinitionName: The property set name to get property set definition.
:returns:
"""
global adoc
with adoc.LockDocument():
with adoc.Database as db:
psdef = None
psdefid = None
newps = False
newpsdef = None
newpsdefid = None
mypsdef = None
mypsdefid = None
with db.TransactionManager.StartTransaction() as t:
dpsd = DictionaryPropertySetDefinitions(db)
psdef = PropertySetDefinition()
psdefid = psdef.Id
dpsd.AddNewRecord("name", psdef)
newps = True
psdefid = dpsd.GetAt("name")
psdef = t.GetObject(psdefid, OpenMode.ForWrite)
definitions = psdef.Definitions
mypsdefid = dpsd.GetAt(propertySetDefinitionName)
mypsdef = t.GetObject(mypsdefid, OpenMode.ForWrite)
mydefinitions = mypsdef.Definitions
for pd in mydefinitions:
definitions.Add(pd)
#aplTo = psdef.AppliesToFilter.Contains.__doc__
#sc = StringCollection()
#scnew = sc.Add("Solid3d")
#psdef.SetAppliesToFilter(scnew, False)
#newpsdef = PropertySetDefinition()
#newpsdefid = newpsdef.Id
#dpsd.AddNewRecord("name", newpsdef)
#newpsdef = t.GetObject(newpsdefid, OpenMode.ForWrite)
#newpsdef.Definitions = definitions
t.AddNewlyCreatedDBObject(psdef, True)
t.Commit()
return mydefinitions, definitions
Here is what was missing:
psdef.AppliesToAll = False
sc = StringCollection()
sc.AddRange(Array[str](["AcDb3dSolid"]))
psdef.SetAppliesToFilter(sc, False)