da_muel Posted November 26, 2010 Share Posted November 26, 2010 Hi, Am totally new to scripting but am keen to start to understand how they work and what they do. Does anyone know of a script that exists or could anyone help me to write a script that will take the name of a symbol (from resource browser) and put it into the name field of the record? Tell me if this is a stupid request but it could be a massive time saver for me! Thanks Sam Also where's the best place to start out with writing scripts and are there any good resources for downloading pre-scripted scripts from. Quote Link to comment
da_muel Posted November 26, 2010 Author Share Posted November 26, 2010 Thanks Blind Expert, Am a total newbie to scripts and have tried what you sent but am not totally sure how this is supposed to work. Have tried your script but cant seem to work at the moment, can you advise a little further please? I guess I need to change the fName to fKIT NAME as this is the name the field I want to fill with the name of the symbol but when I do this I get an error message with this portion of the script? My default value for the KIT NAME field is 'Name'. I have created a record with 4 fields (CATEGORY / KIT NAME / COMPONENT / NUMBER) and want to be able to work on these objects in a master library file and then be able to copy them across to other drawings with the records present (so not just applying the record to the symbol once its in the drawing but have it built into the symbol in the resource browser). I have created for example 3 symbols all with different names in the resource browser. The symbols are called; Platform 1x1 Platform 1x0.5 Platform 0.5x0.5 etc . . . I would like to figure out how to get the name of the symbol and put it into the field KIT NAME in the record within the symbol. Does that make sense - sorry if Im missing something. Thanks again Quote Link to comment
da_muel Posted November 29, 2010 Author Share Posted November 29, 2010 Hi, Thanks very much for coming back to me and sorry if Im confusing! Just trying (obviously not very clearly) to explain how Im trying to make this work. I really appreciate you persevering with me. The script you sent works now that Ive changed the name of the field to Symbolname but its still not quite what Im after although its extremely close. What I want to do is attach record formats to a symbol definition from the Resource Browser and have the script copy the name of the symbol to the name field in the record. Sorry if I didn't make this clear enough. To help make it clear I have pasted the info from VW help to explain the process Im going through and where Im trying to do this. I want to be able to run the script to get the name from the symbol at stage 7 in the process below. "Attaching Record Formats to a Symbol Definition To attach record formats to a symbol definition from the Resource Browser: 1. Select Window > Palettes > Resource Browser. The Resource Browser opens. 2. Select a symbol definition. 3. Select Edit from the Resources menu. 4. Select the symbol component to edit, and click Edit. 5. In the Edit Symbol window, deselect all by clicking in an empty area of the window. 6. In the Object Info palette, click on the Data tab. When no items are selected, the Data tab displays *SYMBOL DEFAULTS* at the top. 7. Select the record to attach. To attach multiple records to the same symbol definition, click on each of the records. 8. Click Exit Symbol at the top right of the Edit Symbol window." Thanks again for your help with this and I hope Ive done a better job of explaining what Im trying to do? I already have another use for the first script you wrote so thanks for that. Sam Quote Link to comment
da_muel Posted November 29, 2010 Author Share Posted November 29, 2010 Ok - thanks for looking at this anyway Blind Expert. Very much appreciated. If there is anyone else out there who has a solution to this Id love to hear from you? Quote Link to comment
maarten. Posted November 29, 2010 Share Posted November 29, 2010 I'm not completely sure what you want to do, but with this script, all the Symbols Definitions in the document will get the record 'RecordName' attached and in the field 'RecordField', the name of the Symbol Definition will be placed. PROCEDURE da_muel; CONST Rname = 'RecordName'; Fname = 'FieldName'; VAR id,aant,tel : INTEGER; h : HANDLE; BEGIN id:=BuildResourceList(16,0,'',aant); IF aant<>0 THEN FOR tel:=1 TO aant DO BEGIN h:=GetResourceFromList(id,tel); SetRecord(h,Rname); SetRField(h,Rname,Fname,GetActualNameFromResourceList(id,tel)); END; END; RUN(da_muel); Quote Link to comment
da_muel Posted November 29, 2010 Author Share Posted November 29, 2010 Hi maarten - thats great. Just what I was after, absolutely spot on. Thanks so much - you have saved me hours of copying and pasting text and getting names wrong. Thanks a million! Sam Quote Link to comment
da_muel Posted November 30, 2010 Author Share Posted November 30, 2010 Thanks both for your help with this. After you both raised concerns about naming records the same as symbols I did a bit of further reading and experimenting. I now understand why you were questioning why I wanted to match the record name to the symbol name. I hadn't been able to create a worksheet that displayed record information as well as the symbol names but have now figured it out! Looking at it its pretty obvious now but just got distracted by other parts of the problem. Thanks - am looking at this all with a clearer idea of how to create my worksheets now. Sorry of the request seemed a bit strange in the first place. Cheers Sam 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.