I'm not a fancy API guy, but this quick-n-dirty might work.
Create layers on the drawing template with notes on them. The notes could have references to the custom properties you want to show/hide.
By default they could be hidden and there's an easy macro for hiding / revealing layers.
Of course if I weren't so lazy I'm sure there's easy code for inserting a pre-determined note at coordinates (x,y).
Here's my code for a show/hide toogle of a layer that has an alignment grid on it.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swLayerMgr As SldWorks.LayerMgr
Dim swLayer As SldWorks.Layer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swLayerMgr = swModel.GetLayerManager
Set swLayer = swLayerMgr.GetLayer("15 - GRID")
If swLayer.Visible = False Then
' Toggle layer on
swLayer.Visible = True
Debug.Assert True = swLayer.Visible
' Toggle layer off
swLayer.Visible = False
Debug.Assert False = swLayer.Visible
thank you for the reply. your macro shows me another way to achieve it.
But i prefer to display the values directly using macro.
You need to display the property as linked OR want just the value?
i just want to display the value of the custom property.
Try these codes
Option Explicit Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDraw As SldWorks.DrawingDoc Dim swView As SldWorks.View Dim swCustProp As CustomPropertyManager Dim Note As SldWorks.Note Dim swAnn As SldWorks.Annotation Dim valOut As String Dim rValOut As String Sub main() Set swApp = Application.SldWorks Set swDraw = swApp.ActiveDoc Set swView = swDraw.GetFirstView Set swView = swView.GetNextView Set swModel = swView.ReferencedDocument Set swCustProp = swModel.Extension.CustomPropertyManager(swView.ReferencedConfiguration) swCustProp.Get2 "DesignedBy", valOut, rValOut 'Change the custom property name here Debug.Print "$PRP:" + Chr(34) + "DesignedBy" + Chr(34) Set Note = swDraw.InsertNote(rValOut) ' Use "$PRPSHEET:" + Chr(34) + "DesignedBy" + Chr(34) in case you want to link to property Set swAnn = Note.GetAnnotation swAnn.SetPosition2 0, 0, 0 'Change note position here End Sub
Thank you Deepak,
it works well.
for read the custom properties from the default model (we do not have any other configurations in the part), i have changed the line as:
Set swCustProp = swModel.Extension.CustomPropertyManager("")
Since you said configuration in the first post, I used configuration properties. Glad to know that you got it working
Thank you again.
is there any method to automatically run this macro when i open a drawing (or upon rebuild, or upon save)?