Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ACAD Mechanical 2019: Manipulate overridden assembly properties with LISP/API/other...

5 REPLIES 5
Reply
Message 1 of 6
Bram_Baars
987 Views, 5 Replies

ACAD Mechanical 2019: Manipulate overridden assembly properties with LISP/API/other...

We have many AutoCAD Mechanical dwg files from times we didn't work with Productstream/Vault, and with items. In those old files, there often is some BOM- and assembly information, not on purpose. For example: from working with an different content center, or external drawings from customers.

We currently manage AutoCAD BOM's manually, in the Vault item, and therefore require AutoCAD to not add information hthere.

 

Now that we work with Vault Professional and with items, this information in the mechanical dwg is messing up our item administration: after using copy design on such a document and assigning it to an item, the dwg is oftenly associated with a wrong item, or with the wrong Associated File Link Type.

 

We've been able to write some code which removes the BOM information in most of the used dwg files. This LISP routine runs automatically before checkin of the file. (sometimes we still have to copy all geometry to a blank template.dwg to get rid of all legacy BOM data)

 

The issue I require some help with, is the following:

Many of these files have an overridden "Name" property, in the "Assembly properties", as can be seen on the attached screenshot. This override results in the wrong item being assocated with the file (when using "Assing/Update item..." in Vault).

 

  • Would it be possible to manipulate this property through LISP, to always remove the override?
Labels (1)
5 REPLIES 5
Message 2 of 6
CodeDing
in reply to: Bram_Baars

@Bram_Baars ,

 

I don't have Mechanical, but can you post an example dwg with what you are trying to change, so we can test? That would be very beneficial to others trying to help.

 

Best,

~DD


Need AutoLisp help? Try my custom GPT 'AutoLISP Ace':
https://chat.openai.com/g/g-Zt0xFNpOH-autolisp-ace
Message 3 of 6
Bram_Baars
in reply to: CodeDing

Of course, and thanks for the suggestion!

 

I included an example.dwg in the attachment. I purged all geometry, and confirmed that the override is still present.

Message 4 of 6
Bram_Baars
in reply to: Bram_Baars

Is it possible to remove the override below, using LISP?

Bram_Baars_0-1620205435286.png

 

Message 5 of 6
Bram_Baars
in reply to: Bram_Baars

LISP is not a necessity; we're pretty close when reading this example, using the API, but don't know how to undo the override:


https://adndevblog.typepad.com/manufacturing/2012/07/get-assembly-properties-from-autocad-mechanical...

 

Message 6 of 6
Anonymous
in reply to: Bram_Baars

Hello,

From the adndevblog i got below vba code and with the code the assembly propterties component name can be adjusted (see "new_name") but I cannot figure out how to remove the override on the name property.

Some help would be appreciated. 

Sub setgetAssemblyAttributes()

   

    ' Set reference to symbol Manager

    Dim symbb As McadSymbolBBMgr

    Dim bommgr As McadBOMMgr

    Dim stdmgr As McadStandardMgr

   

    Set symbb = ThisDrawing.Application.GetInterfaceObject("SymBBAuto.McadSymbolBBMgr")

    Set bommgr = symbb.bommgr

    Set stdmgr = symbb.StandardMgr

      

    ' Check if the assembly properties have been initialized

   

    ' Get the assembly attributes from current database modelspace

    Dim vdata As Variant

    vdata = bommgr.GetPartData(ThisDrawing.ModelSpace)

   

    'If VarType(vdata) = vbEmpty Then

   

        'Create the data to be assigned

        ' Define double array of strings to hold column name and values

        Dim sData(0 To 10, 0 To 1) As String

        sData(0, 0) = "NAME": sData(0, 1) = "new_name"

        sData(1, 0) = "STANDARD2": sData(1, 1) = "text for standard2"

        sData(2, 0) = "DIM": sData(2, 1) = "10"

        sData(3, 0) = "DESCR2": sData(3, 1) = "10"

        sData(4, 0) = "PRICE": sData(4, 1) = "100"

        sData(5, 0) = "MASS": sData(5, 1) = "101"

        sData(6, 0) = "MATERIAL": sData(6, 1) = "IS:2062"

        sData(7, 0) = "VENDOR": sData(7, 1) = "XYZ"

        sData(8, 0) = "DESCR": sData(8, 1) = "text for description"

        sData(9, 0) = "MATERIAL2": sData(9, 1) = "GOLD"

        sData(10, 0) = "STANDARD": sData(10, 1) = "text for standard"

       

        ' Assign the data to current database modelspace

‘Call bommgr.SetPartAttribute(ThisDrawing.ModelSpace, “NAME”, “”)

        Call bommgr.SetPartData(ThisDrawing.ModelSpace, sData)

   ' Else

        ' print the existing data

       ' Dim j As Integer

       

        ' For j = LBound(vdata) To UBound(vdata)

           ' Debug.Print vbTab + vdata(j, LBound(vdata, 2)) + vbTab _

           ' + vbTab + vbTab + vdata(j, UBound(vdata, 2)) + vbCrLf

       ' Next

   ' End If

 

End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report