‹#›
© 2008 Autodesk
ADSK_BLack_BAR.png
ADN Webcasts 2008
§Sub convertToStructure()
§    ' 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 acBlockRef As AcadBlockReference
§    Dim pt(2) As Double
§   
§    Call ThisDrawing.Utility.GetEntity(acBlockRef, pt, vbCrLf & "Select block reference to convert")
§   
§    ' add the object to the array
§    Dim ids(0) As Long
§    ids(0) = ThisDrawing.Blocks(acBlockRef.Name).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 = acBlockRef.Name
§    Call acmCD.AddComponentView(acmCVD)
§   
§    Dim varFDs As Variant
§    Dim varCDs(0) As Variant
§    Set varCDs(0) = acmCD
§   
§    Call acmSM.CreateStructureFromBlocks(varCDs, varFDs)
§End Sub
GeAuto