You can display objects symbol in a diagram using the following methods:
AttachObject(ByVal Obj As BaseObject) As BaseObject to create a symbol for a non-link object
AttachLinkObject(ByVal Link As BaseObject, ByVal Sym1 As BaseObject = NULL, ByVal Sym2 As BaseObject = NULL) As BaseObject to create a symbol for a link object
AttachAllObjects() As Boolean to create a symbol for each object in package which can be displayed in current diagram
If not ExistingModel Is Nothing and not MyRealization Is Nothing Then ' Symbols are specific kind of objects that can be manipulated by script ' We are now going to display the class, interface and realization in the ' main diagram of the model and customize their presentation ' Retrieve main diagram Dim MyDiag Set MyDiag = ExistingModel.DefaultDiagram If not MyDiag is Nothing and MyDiag.IsKindOf(PdOOM.Cls_ClassDiagram) Then ' Display the class, interface shortcut and realization link in the diagram ' using default positions and display preferences Dim MyClassSym, MyIntfSym, MyRlzsSym Set MyClassSym = MyDiag.AttachObject(FoundClass) Set MyIntfSym = MyDiag.AttachObject(IntfShct) Set MyRlzsSym = MyDiag.AttachLinkObject(MyRealization, MyClassSym, MyIntfSym) If not MyRlzsSym is Nothing Then output "Objects have been successfully displayed in diagram" End If ' Another way to do the same is the use of AttachAllObjects() method: ' MyDiag.AttachAllObjects ' Changes class symbol format If not MyClassSym is nothing Then MyClassSym.BrushStyle = 1 ' Solid background (no gradient) MyClassSym.FillColor = RGB(255, 126, 126) ' Red background color MyClassSym.LineColor = RGB(0, 0, 0) ' Black line color MyClassSym.LineWidth = 2 ' Double line width Dim Fonts Fonts = "ClassStereotype " + CStr(RGB(50, 50, 126)) + " Arial,8,I" Fonts = Fonts + vbCrLf + "DISPNAME " + CStr(RGB(50, 50, 50)) + " Arial,12,B" Fonts = Fonts + vbCrLf + "ClassAttribute " + CStr(RGB(150, 0, 0)) + " Arial,8,N" MyClassSym.FontList = Fonts ' Change font list End If ' Changes interface symbol position If not MyIntfSym is nothing Then Dim IntfPos Set IntfPos = MyIntfSym.Position If not IntfPos is Nothing Then IntfPos.x = IntfPos.x + 5000 IntfPos.y = IntfPos.y + 5000 MyIntfSym.Position = IntfPos Set IntfPos = Nothing End If End If ' Changes the link symbol corners If not MyRlzsSym is Nothing Then Dim CornerList, Point1, Point2 Set CornerList = MyRlzsSym.ListOfPoints Set Point1 = CornerList.Item(0) Set Point2 = CornerList.Item(1) CornerList.InsertPoint 1, Max(Point1.x, Point2.x), Min(Point1.y, Point2.y) Set CornerList = Nothing ' Max and Min are functions defined at end of this script End If ' Release the variables Set MyDiag = Nothing Set MyClassSym = Nothing Set MyIntfSym = Nothing Set MyRlzsSym = Nothing End If End If