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)
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.