Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

macro for copying material

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
akosi
750 Views, 8 Replies

macro for copying material

hi,

 

can someone help me do a macro?

 

i want to pick the part material in my assy and copy it to a the same assy custom prop.

 

many thanks

inventor 2013

vault 2013

8 REPLIES 8
Message 2 of 9
augusto.goncalves
in reply to: akosi

I would suggest you start with this blog post: http://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html

 

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 3 of 9
akosi
in reply to: augusto.goncalves

can somebody help me do a simple code to display in msgbox the material of the part ?

 

thanks

Message 4 of 9
jdkriek
in reply to: akosi

Correct me if I am wrong, you are wanting to be able to click a part inside an Assembly and display the material for that part in a msgbox inside the Assy? And you also want to copy that material to a custom property inside the Assy?

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 9
akosi
in reply to: akosi

yes... thats exactly what i want to do...

 

is it possible?Smiley Frustrated

Message 6 of 9
jdkriek
in reply to: akosi

Sure anything is possible 😉

 

I suggest you study the code, it's very simplistic.

 

Public Sub MatCopy()
'JDK 2013
    On Error Resume Next
    
    ' Get the Assy Document
    Dim oAssDoc As AssemblyDocument
    Set oAssDoc = ThisApplication.ActiveDocument
    
    ' Select occurrence
    Dim oOccurrence As ComponentOccurrence
    Set oOccurrence = oAssDoc.SelectSet.Item(1)
        If Err Then
            MsgBox "An occurrence must be selected."
            Err.Clear
            On Error GoTo 0
            Exit Sub
        End If
    
    ' Define name and material as strings
    sName = oOccurrence.name
    sMat = oOccurrence.Definition.Material.name
    
    ' Get custom property set
    Dim customPropSet As PropertySet
    Set customPropSet = oAssDoc.PropertySets( _
    "Inventor User Defined Properties")
    
    ' Add new property with name and material
    Call customPropSet.Add(sMat, sName)
    
    ' Msg the material
    MsgBox (sName & " = " & sMat)
End Sub
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 7 of 9
akosi
in reply to: jdkriek

you save my day!!!

 

thank you so so so much..

 

what does this code mean? On Error GoTo 0

what is zero?

 

Message 8 of 9
akosi
in reply to: jdkriek

ive change  sName to some namexxx.

 Call customPropSet.Add(sMat, sName)

 

 

id like to add a code for deleting the namexxx if it exist..

 

thank you so much  Smiley Happy

Message 9 of 9
jdkriek
in reply to: akosi

On Error GoTo 0 disables any error trapping currently present in the procedure.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


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

Post to forums  

Autodesk Design & Make Report