×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to modify template descriptions through Solidworks API

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!
 

RE: How to modify template descriptions through Solidworks API

cam10,
       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

(OP)
It is unknown from one drawing to the next as to how many pages there are going to be, so this has to be created on the fly.

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources