Another quick one today. I’ve got some large models which are divided into packages. I’m automating some tasks with scripts which I can configure using extended attributes (see earlier posts).
Let’s say I have a parameter for a script called “Audit” which can be true or false. My model is divided into 3 packages, each containing a set of tables. I want to set the default for the model to be True and have the script behave appropriately if I don’t do anything else. I’d also like to be able to override it for a package and have the script work appropriately. And since packages can be nested (although I haven’t seen it done much), the script needs to handle that as well. Easy enough with a little recursion. Create the same named extended attribute at each level (Model and Package) and use a global script to resolve it.
Here’s the script:
function getExtendedAttr(startObj, attrName) dim par dim attrVal set par = startObj.Parent if par is nothing then output "Error in getExtendedAttr" else attrVal = par.getExtendedAttributeText(attrName) if attrVal = "" then if par = activeModel then getExtendedAttr = "" else getExtendedAttr = getExtendedAttr(par, attrName) end if else getExtendedAttr = attrVal end if end if end
Now, instead of using
obj.GetExtendedAttribute("Audit")
I use
getExtendedAttr(obj, "Audit")
Done.
Discussion
No comments yet.