§Sub createStructure()
§ ' get
application objects
§ Dim acmApp As AcadmApplication
§ Set acmApp =
ThisDrawing.Application.GetInterfaceObject("AcadmAuto.AcadmApplication")
§
§ Dim geApp As GeApplication
§ Set geApp =
Application.GetInterfaceObject("Ge.Application")
§
§ ' select
object for the component
§ Dim acEnt As AcadEntity
§ Dim pt(2) As
Double
§
§ Call ThisDrawing.Utility.GetEntity(acEnt,
pt, vbCrLf & "Select an object for the component")
§
§ ' add the
object to the array
§ Dim ids(0) As Long
§ ids(0) =
acEnt.ObjectID
§
§ ' get the
structure manager
§ Dim acmSM As Mcad2DStructureMgr
§ Set acmSM =
acmApp.ActiveDocument.StructureMgr2D
§
§ ' create a
view
§ Dim acmCVD As McadComponentViewDescriptor
§ Set acmCVD =
acmSM.CreateComponentViewDescriptor
§ acmCVD.Name = "Top"
§ acmCVD.Entities = ids
§ acmCVD.Position = geApp.Matrix
§
§ ' create a
component
§ Dim acmCD As Mcad2dComponentDescriptor
§ Set acmCD =
acmSM.Create2dComponentDescriptor
§ acmCD.Name = "COMP_" &
acEnt.Name
§ acmCD.OwningComponentDefinition =
acmSM.RootComponentDefinition
§ Call acmCD.AddComponentView(acmCVD)
§ acmCD.CreateComponent
§End
Sub