Below is a VBA example, which shows how to insert part reference and set
part reference attributes. You will have to reference to "Autodesk SymBBAuto
2.0 Type Library".
Sub createPartReference()
Dim oAcApp As AcadApplication
Dim oAcUtil As AcadUtility
Set oAcApp = GetObject(, "AutoCAD.Application")
Set oAcUtil = oAcApp.ActiveDocument.Utility
Dim pt As Variant
pt = oAcUtil.GetPoint(, "Location for ampartref: ")
pt = oAcUtil.TranslateCoordinates(pt, acUCS, acWorld, False)
Dim oPartref As McadPartReference
Set oPartref = ThisDrawing.ModelSpace.AddCustomObject("AcmPartRef")
oPartref.Origin = pt
Dim oSymbb As McadSymbolBBMgr
Set oSymbb =
ThisDrawing.Application.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr")
Dim oBommgr As McadBOMMgr
Set oBommgr = oSymbb.BOMMgr
Dim pdata(0 To 5, 0 To 1) As String
pdata(0, 0) = "DESCR": pdata(0, 1) = "My Description"
pdata(1, 0) = "STANDARD": pdata(1, 1) = "My Standard"
pdata(2, 0) = "MATERIAL": pdata(2, 1) = "My material"
pdata(3, 0) = "NOTE": pdata(3, 1) = "My note"
pdata(4, 0) = "VENDOR": pdata(4, 1) = "My vendor"
pdata(5, 0) = "NAME": pdata(5, 1) = "Comp1"
oBommgr.SetPartData oPartref, pdata
ThisDrawing.Application.Update
End Sub
---
Kar Poh
Developer
Manufacturing Solutions Division
Autodesk, Inc.
wrote in message news:4878834@discussion.autodesk.com...
In my VBA macro I want insert a new part reference. Which command I must
use? Have you an example? Thanks
Best regards
Note: I use Autocad Mechanical 2004 DX