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
Solved! Go to Solution.
Solved by jdkriek. Go to Solution.
I would suggest you start with this blog post: http://modthemachine.typepad.com/my_weblog/2009/03/accessing-assembly-components.html
can somebody help me do a simple code to display in msgbox the material of the part ?
thanks
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
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