sorry, i'm a noob to this. i've written the following attempting to add attributes to a physical model but below when i attempt:
MyAttribute.DefaultName = "timestamp now"
it doesn't work.
i'm tryin g to set the default value from the data dictionary defaults.
the code:
Sub Main Dim MyDiagram As Diagram Dim MyModel As Model Dim MyEntity As Entity Dim MyAttribute As AttributeObj Set MyDiagram = DiagramManager.ActiveDiagram Set MyModel = MyDiagram.ActiveModel If Not MyModel.Logical Then If MsgBox("This macro will add audit columns to all objects.", vbOkCancel) = vbOK Then For Each MyEntity In MyModel.Entities MsgBox(MyEntity.EntityName) Set MyAttribute = MyEntity.Attributes.Add("create_date", False) MyAttribute.Datatype = "TIMESTAMP" MyAttribute.Definition = "The datetime the record was created." MyAttribute.NullOption = "NOT NULL" MyAttribute.DefaultName = "timestamp now" 'not working MsgBox(MyAttribute.Datatype) MsgBox(MyAttribute.Definition) Next End If Else MsgBox "This macro is designed to run in the Physical model. Please switch to Physical model first." End If End Sub
figured it out:
For Each MyDefaults In MyDiagram.Dictionary.Defaults If MyDefaults.Name = "timestamp now" Then Set MyTimestampNowDefaultId = MyDefaults.ID
...
MyAttribute.DefaultId = MyTimestampNowDefaultId
I'm doing something very similar, would you share the completed script? Did you add a dictionary entry manually that you reference? Thanks for any info!