MattG Posted October 17, 2016 Share Posted October 17, 2016 Long back story here, but the quick summary is as follows. We have a file here a guy is working on. We have lots and lots of symbols in it. I am trying to link one block of text in each symbol to one record field. Right now we do the following. Select the symbol - Edit 2D - select the text - choose from the menu "link text to record" - choose the record & the field- exit the symbol. What I am hoping is that I can generate some type of a script that after the text is selected would automatically go to "Menu - Tools - Records - Link Text to record - automatically choose the Format and the field in there as they are all the same and hit okay." Is there any way to automate that into a script or something where we can just select 1 button to make everything execute as follow? Quote Link to comment
michaelk Posted October 17, 2016 Share Posted October 17, 2016 Are there ever two blocks of text in a symbol? Do the symbol definitions already have a link to the record format? Quote Link to comment
MattG Posted October 17, 2016 Author Share Posted October 17, 2016 Yes and yes There are mabye 6-12 blocks of text per symbol. Most all the symbols already have this record applied to them, just not the text linked to record. The hope is once the given text block is selected to save the couple of steps to link to that record and field. Matt Quote Link to comment
michaelk Posted October 17, 2016 Share Posted October 17, 2016 Does the text already in the symbol become the value in the record field, or should a default value be used? Quote Link to comment
MattG Posted October 17, 2016 Author Share Posted October 17, 2016 It becomes the value most of the time. The one in question is a weight value for a bunch of odd pieces we have in a sort of master drawing. The record is already attached with a given value, but it wants to be shown in the corner of the symbol. Matt Quote Link to comment
Pat Stanford Posted October 17, 2016 Share Posted October 17, 2016 Are you going to write this one Michael or should I try to find some time? Quote Link to comment
michaelk Posted October 17, 2016 Share Posted October 17, 2016 (edited) I don't dare race you. :-) I have some time tonight and travel time tomorrow. I think I can figure it out. As long as it doesn't need to be elegant. Matt, if you need it before then, Pat could find 15 minutes and crank it out. mk edit: Pat, even if you do it, I probably give it a try, just for the fun/experience. Edited October 17, 2016 by michaelk Quote Link to comment
MattG Posted October 18, 2016 Author Share Posted October 18, 2016 No major hurry or anything just working on something here, it is an inventory of some pieces we own. It can really be put together more or less whenever. It is more of a curiosity thing. I am also very curious how to do this myself. I know some super basic scripting, but not sure how to execute this. I would appreciate any insight. Thanks, Matt Quote Link to comment
michaelk Posted October 18, 2016 Share Posted October 18, 2016 Interesting. @Pat Stanford I may turn this one over to you. What I thought was going to be simple is complicated by starting the script while inside the symbol definition. Not sure how to proceed. Is it necessary to create a dummy symbol and do a SetHDef(); ? Or is it necessary to close the edit first? I'm stumped. I'm sure when I land you'll have an elegant 12 line script :-) mk Quote Link to comment
Pat Stanford Posted October 19, 2016 Share Posted October 19, 2016 Yes, definitely more than I expected. It currently looks like either I am doing something wrong with Get/SetObjectVariables or there is a bug/problem with some of the object variables relating to linking text to record. At this time, what is wanted may not be possible, but I will keep pondering it. Quote Link to comment
michaelk Posted October 20, 2016 Share Posted October 20, 2016 Did you find that it works on a text object outside the symbol? mk Quote Link to comment
Pat Stanford Posted October 20, 2016 Share Posted October 20, 2016 No. The Get/SetObjectVariableInt(H1,1350/1351) do not seem to work at all. The only return I get from these calls is 0. I am planning to submit a bug the next time I get a chance. I tried Int, LongInt, String, Handle, Point, Boolean. None of them return anything but zero for a text object in a symbol that is linked to a record or is not linked to a record. Apologies for typos. Too much scotch. Pat Quote Link to comment
Pat Stanford Posted October 26, 2016 Share Posted October 26, 2016 I have gotten to be able to get the record and field of a block of linked text, but I have not figured out how to create the link. There is certainly no easy way to do it in vanilla Vectorscript (or Python), but I am still playing. 1 Quote Link to comment
MullinRJ Posted October 30, 2016 Share Posted October 30, 2016 Pat, like you, I've spent WAY more time on this than I intended, but I think I've got it — assuming I read the question correctly. Then I spent a bunch more time playing with it. All of it non billable, so I hope someone enjoys this besides me. MattG, Having never worked with Linked Text before, I started out like a rank beginner. Now I understand how it works. It weren't [sic] obvious. I am also not sure I solved the problem you stated above. Hopefully I am close. I'm attaching a v2013 file with 3 scripts. The first converts "symbols with selected text" to "symbols with Linked Text", and it makes a LOT of assumptions on how the file is set up. A list of the assumptions can be found at the top of the script. Use the Script Editor to read them. If anyone uses this script on their own files — WORK ON A COPY OF YOUR WORK – until you know the script does what you want. All Common Sense Disclaimers apply. Because this task starts with symbol instances and ends up modifying symbol definitions, it was necessary to make two passes to do it right. Here's my basic approach: With each symbol instance: find the first selected text object inside the SymDef. attach the LinkedText record to the symbol instance. add the selected text from inside the SymDef to the record field. Go back through each symbol instance: find the first selected text object inside the SymDef. attach the Linked Text record to the SymDef. add the selected text from inside the SymDef to the record field. This is the Default text when the symbol is placed. LinkText() from the selected text object to the Linked Text record and field. The second script places symbols and modifies the Linked Text. The third script resets the file to its initial state. If anyone has any questions about what I've done, Pat will be happy to answer you. ;-) Raymond Link SymText to Sym v2013.vwx 1 Quote Link to comment
DomC Posted April 11, 2018 Share Posted April 11, 2018 Incredible usefull stuff! Many 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.