How to modify template descriptions through Solidworks API
How to modify template descriptions through Solidworks API
(OP)
I am a programmer (not a pool man!)
If we have multiple pages in a Solidworks Drawing file, we want to be able to set a different page description for each. The section description remains the same for all.
I access the model template as follows to find the note
and in this case "$PRP:PageDescription"
"Set swdraw = swmodel
swdraw.edit template
set view = swdraw.getfirstview
set note = view.getfirstnote
snotename = note.getname
snotename = note.propertylinkedtext()
....then I search for the applicable field "PageDescription" and because I have already added another "PageDescription", I tack a number on it that coincides with the page number I want to access, ie "PageDescription2".
I have already stored this in the Custom Properties, but now need to associate it with the actual "Editsheet" function for the drawing template.
I find "$PRP: " & Chr(34) & "PageDescription" & Chr(34)
and want to override it with "$PRP: " & Chr(34) & "PageDescription2" & Chr(34). Keep in mind it is just for this page. When I retrieved the text value I would set the value = note.GetText. Instead of changing the text value I want to set the new description. I thought I might be able to use this same object and use something like note.Getname, but that doesn't seem to work.
Your assistance is appreciated!
If we have multiple pages in a Solidworks Drawing file, we want to be able to set a different page description for each. The section description remains the same for all.
I access the model template as follows to find the note
and in this case "$PRP:PageDescription"
"Set swdraw = swmodel
swdraw.edit template
set view = swdraw.getfirstview
set note = view.getfirstnote
snotename = note.getname
snotename = note.propertylinkedtext()
....then I search for the applicable field "PageDescription" and because I have already added another "PageDescription", I tack a number on it that coincides with the page number I want to access, ie "PageDescription2".
I have already stored this in the Custom Properties, but now need to associate it with the actual "Editsheet" function for the drawing template.
I find "$PRP: " & Chr(34) & "PageDescription" & Chr(34)
and want to override it with "$PRP: " & Chr(34) & "PageDescription2" & Chr(34). Keep in mind it is just for this page. When I retrieved the text value I would set the value = note.GetText. Instead of changing the text value I want to set the new description. I thought I might be able to use this same object and use something like note.Getname, but that doesn't seem to work.
Your assistance is appreciated!






RE: How to modify template descriptions through Solidworks API
What I would suggest is to control your descriptions in the model. Have your sheet 1 description called $PRPSHEET:"PageDescription1" and sheet 2 called $PRPSHEET:"PageDescription2". No programming would be needed. Your sheet 1 would read PageDescription1 property and your sheet 2 template would read PageDescription2 property. Then you can write your code to work on the descriptions outside the drawing sheet.
Bradley
SolidWorks Pro 2009 x64, SP2.0
PDMWorks Workgroup, SolidWorks BOM,
HP xw8600,
64-bit Windows Vista Business
Service Pack 1
Intel Xeon CPU, 3.00 GHz, 16 GB RAM, Virtual memory 166682 MB,
nVidia Quadro FX 4600 Driver 7.15.11.6956
RE: How to modify template descriptions through Solidworks API
I found the solution already...I needed to pass the variable of the new description (strTitles) field (took existing and add a number to represent the actual page on the drawing) surrounded by chr(34). This worked!
Do While Not Note Is Nothing
sNoteName = Note.GetName
sNoteName = Note.PropertyLinkedText()
If (Note.PropertyLinkedText = "$PRP:""PageDescription""") Then
Note.PropertyLinkedText = "$PRP:" & Chr(34) & strTitles & Chr(34)
swDraw.EditSheet
Exit Function
Else
If (Note.PropertyLinkedText = "$PRP:""FieldYesNo""") Then
Note.PropertyLinkedText = "$PRP:" & Chr(34) & strTitles & Chr(34)
swDraw.EditSheet
Exit Function
End If
End If
Set Note = Note.GetNext
Loop