We use scripts to automate repetitive tasks, and that usually means things like creating tables, columns, views, etc. So, I’ve generally gotten pretty fast at putting together those types of scripts. For my last script, I wanted to create a view on top of a set of tables, and create an extended dependency to link them together. By putting a stereotype on the extended dependency, I would always be able to identify the particular view created by these scripts, no matter what changes were made to them.
Typically we create a new object by doing something like:
dim extDep set extDep = obj.ExtendedDependencies.CreateNew()
No luck. I tried a few variations, and then hit the groups. I found several examples for creating extended dependencies:
ExDepColl=ActiveModel.GetChildCollPdCommon.cls_extendedDependency) Set NewExtendedDependency =ExDepColl.CreateNew(0) NewExtendedDependency.InfluentObject = BaseTable NewExtendedDependency.DependentObject = HistoryTable ActiveDiagram.AttachLinkObject(NewExtendedDependency)
and
Set EDep = prc.ExtendedDependencies.CreateNew() Set EDep.InfluentObject = IObj EDep.Stereotype = ed.Stereotype
Unfortunately, I could not get either to work, and while I’m certainly willing to admit the problem may lie between the keyboard and chair, what I eventually found that did work was:
Set ExtDep = ActiveModel.CreateObject(cls_ExtendedDependency)
obj.ExtendedDependencies.Add(ExtDep)
So, the key is to first create an object of type cls_ExtendedDependency THEN use the Add method to put it in the ExtendedDependencies collection.
Thanks Rich! This is very useful. Do you know how I add a ExtendedDependencies of a table? I can insert a line on a view ExtendedDependencies propertie, but I need to specify the reference.
Thanks in advance for your help.
Wow, there’s a lot of comments here and I recently discovered that I wasn’t getting notified of them. So I apologize for anyone I’ve missed and here’s a code snippet for the most recent question.
To create an extended dependency you need to first create the dependency, then add it to the collection on your first object . Then you set the influentobject property to the second .
Set ExtDep = ActiveModel.CreateObject(cls_ExtendedDependency)
.ExtendedDependencies.Add(ExtDep)
Set ExtDep.InfluentObject =
Hope this helps.