AnsweredAssumed Answered

Copy custom properties from parts and assemblies to drawings

Question asked by Nicholas Almond on May 9, 2019
Latest reply on May 10, 2019 by Christian Chu

We produce parts, assemblies and drawings for fabricators and rely heavily on custom properties. We export each drawing out as a PDF in the format: PART-NO.REVISION-LETTER.PDF. For example: SW001.issueA.PDF. This is saved and renamed manually despite the revision letter being in the custom properties.

 

When producing a new drawing for the part, the revision letter correctly pulls through to the drawing, but not to the custom properties. See below:

 

 

 

One solution was to use a macro to pull through the custom properties from the part to populate the drawing. This appeared to partially work but only on fields that were text (not drop-down menus) and only on parts. I'd need something to pull through custom properties from both parts and assemblies. Also, to pull through ALL of the fields. I stumbled across the below macro which only some way does what I need:

 

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim swmodel As SldWorks.ModelDoc2

Dim swmod As SldWorks.ModelDoc2

Dim swdraw As SldWorks.DrawingDoc

Dim swview As SldWorks.View

Dim v As Variant

Dim Propname As Variant

Dim evval As Variant

Dim model As String

Dim error As Long

Dim warning As Long

Dim config As Variant

Dim addstatus As Long

Dim i As Integer

Dim comp As SldWorks.Component2

Dim swCustPropMgr As SldWorks.CustomPropertyManager

Sub main()

Set swApp = Application.SldWorks

Set swmodel = swApp.ActiveDoc

Set swdraw = swmodel

Set swview = swdraw.GetFirstView

Set swview = swview.GetNextView

v = swview.GetVisibleComponents

Set comp = v(0)

Set swmod = comp.GetModelDoc2

Propname = swmod.GetCustomInfoNames

Set swCustPropMgr = swmodel.Extension.CustomPropertyManager("")

For i = 0 To UBound(Propname)

evval = swmod.GetCustomInfoValue(config, Propname(i))

addstatus = swCustPropMgr.Add2(Propname(i), swCustomInfoText, evval)

evval = ""

Next

End Sub

 

 

Question: Is there a way to link custom properties between parts & assemblies with their linked drawing, without needing a macro?

 

Secondary question: If not, could someone please point me in the right direction for accessing part and assembly custom properties?

 

Any help would be much appreciated!

Outcomes