Martin Crawford Posted March 19, 2019 Share Posted March 19, 2019 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? vs.BeginSym(panelName) 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 vs.TextFont(vs.GetFontID('ClanPro-Medium')) vs.MoveTo(0,0) vs.TextOrigin(0,0) if height_mm > 1000: vs.TextSize(22) elif height_mm > 700: vs.TextSize(18) elif height_mm > 500: vs.TextSize(14) else: vs.TextSize(12) vs.CreateText('ID') 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') vs.EndSym() Quote Link to comment
JBenghiat Posted March 19, 2019 Share Posted March 19, 2019 (edited) You need to attach the record to the symbol. Add as the last line: vsRecord(vs.LNewObject(), ‘L ED Install Panel’ ) Edited March 19, 2019 by JBenghiat Quote Link to comment
Martin Crawford Posted March 20, 2019 Author Share Posted March 20, 2019 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. Martin Quote Link to comment
JBenghiat Posted March 22, 2019 Share Posted March 22, 2019 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. 1 Quote Link to comment
Martin Crawford Posted March 22, 2019 Author Share Posted March 22, 2019 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. Thanks Quote Link to comment
JBenghiat Posted March 22, 2019 Share Posted March 22, 2019 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. Quote Link to comment
Martin Crawford Posted March 22, 2019 Author Share Posted March 22, 2019 Very helpful, I will read up on Red symbols. Thanks Quote Link to comment
Martin Crawford Posted March 22, 2019 Author Share Posted March 22, 2019 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. Thanks Quote Link to comment
Recommended Posts
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.