Jump to content

Recommended Posts

I have the following code that does everything, except link the text to the record. It works if I do it manually, but not in code.


Any thoughts?



        TopX = (width_mm / 2)  * -1
        TopY = (height_mm / 2) 
        BotX = (width_mm / 2) 
        BotY = (height_mm / 2) * -1        
        vs.Rect(TopX, TopY, BotX, BotY)


        #Create the ID Text

        if height_mm > 1000:
        elif height_mm > 700:
        elif height_mm > 500:
        tObj = vs.LNewObj()
        vs.SetTextJust(tObj, 2)
        vs.SetTextVerticalAlign(tObj, 3)
        vs.SetTextWidth(tObj, width_mm)
        vs.SetOpacity(tObj, 30)


        #Link ID Number to ID
        vs.LinkText(tObj, 'LED Install - Panel', 'ID')


Share this post

Link to post

You need to attach the record to the symbol. 


Add as the last line:

vsRecord(vs.LNewObject(), ‘L ED Install Panel’ )


Edited by JBenghiat

Share this post

Link to post

Strange, but this does not seem to make a difference.


When I run the script it creates everything, assigns the record correctly, however it does not link the ID to the record.


I can attach the full py file if that is helpful.



Share this post

Link to post

You may need to attach the record before linking the text.

I would suggest doing a manual link in an otherwise blank file, then exporting to script. Examine the script to check order of operations. That may also reveal something silly, like a spelling error. 


I do have to ask, if you’re coding this, why not just create a plug-in object? That would save you from having to figure out link text to record.

Share this post

Link to post

The script creates around 100 symbols for the different LED panels we use. I'm then have several scripts that create plugins for a full screen. I use the symbols as I'm not sure how I would create a plugin using a plugin and if it would speed up the process. Another reason I use the symbol is I attach the size, weight, resolution, power and other specification data into the symbol that I use in a set of worksheets.


How would I go about creating them as plugins instead of symbols?


I forgot you could export a something as a script, I need to remember that as it would make things easer. I will try the script and see how it works.





Share this post

Link to post

Plug-ins essentially store parameters identically to record data, so a plug-in script can use Set/GetRField to access the data, for example to create text from that data. You can also run reports on plug-in parameters. If you're going the plug-in route, you would have parameters for all the elements you would need for the plug-in to draw the panel. You could save the plug-in as a "Red" symbol (if you're unfamiliar with the term, that's what to search for in the help) for different models.


You can indeed have plug-ins inside other plug-ins, calling CreateCustomObject() from in the PIO code. 


Another way to think about the problem is to still base the PIO on symbols, but have a PIO that uses the symbol for geometry and handles the labels and data management. If your combined screen also needs to have the labels, it could actually also do the work of placing a label for each panel.

Share this post

Link to post

So exporting the scripts showed that the link text happens after the symbol is created and before the record is attached.


I'm not clear on they why, but it works.


I'm still looking at making them on plug-ins, I think it is a better overall solutions.




Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...