Tere Posted June 1, 2021 Share Posted June 1, 2021 Hi everyone, I cannot seem to work out why my lines won't change thinckness. Might I be setting the values in the script wrong? The attached screenshot shows attributes of an example line I need to change. It's thickness is 0.25, and just to see the change clearly, the new thickness would be 1. What am I doing wrong please?? The script otherwise compiles. PROCEDURE LineWeightChange; { © Petri Sakkinen 2008 } CONST { substitute these with the required values } oldWeight = 0.25; newWeight = 1; PROCEDURE ChangeIt (h : HANDLE); BEGIN SETLW(h, newWeight); END; BEGIN FOREACHOBJECT(ChangeIt, LW = oldWeight); END; RUN(LineWeightChange); Thanks for helping! Quote Link to comment
Pat Stanford Posted June 1, 2021 Share Posted June 1, 2021 I think the LW calls require the thickness to be specified in Mils and it looks like you are trying to use mm. 1 Mil = 1/1000 inch = 1/25.4mm You may also have a hard time getting an exact conversion between mm and mil, so you may want to use a less than/greater than range in the comparison about which objects to change. Quote Link to comment
Tere Posted June 1, 2021 Author Share Posted June 1, 2021 Thanks! Actually for this particular task, I literally just need all the lines to be set to black colour and to 0.13 mm, do you think you could help me with how to edit the script so that it does that? For future reference, could you also please advise me on how to use a less than/greater than range in the script please? Thanks so much!! Quote Link to comment
Pat Stanford Posted June 1, 2021 Share Posted June 1, 2021 PROCEDURE LineWeightChange; CONST { substitute these with the required values } newWeight = 0.13; {mm} VAR milWeight: Real; PROCEDURE ChangeIt (h : HANDLE); BEGIN SETLW(h, milWeight); END; BEGIN milWeight = newWeight * 1000 / 25.4; (convert mm to mils) FOREACHOBJECT(ChangeIt, T=2); {This selects lines only, not circles, polys, rectangles, etc.} END; RUN(LineWeightChange); This first one should do what you need (if you meant what you typed ;-). ) by changing all lines to 0.13 mm (or the closest Mil equivalent). This second one shows a way to use a range instead of a direct comparison. PROCEDURE LineWeightChange; { © Petri Sakkinen 2008 } CONST { substitute these with the required values } oldWeight = 0.25; {in mil} newWeight = 1; {in mil} PROCEDURE ChangeIt (h : HANDLE); BEGIN SETLW(h, newWeight); END; BEGIN FOREACHOBJECT(ChangeIt, ((LW <= oldWeight+1) & (LW >= oldWeight-1)); {selects all objects with LW within 1 mil of OldWeight} END; RUN(LineWeightChange); Quote Link to comment
Tere Posted June 1, 2021 Author Share Posted June 1, 2021 The first one shows this error (please see screenshot) when I try and run it? Also, I would probably want to include polys, rectangles, maybe even circles for the search for this one... Thanks for your help! Quote Link to comment
Tere Posted June 1, 2021 Author Share Posted June 1, 2021 (btw the second one shows this error page..I am a beginner so resolving errors takes super long and usually does not lead anywhere, but I will get there and pick it up :)) Quote Link to comment
Pat Stanford Posted June 1, 2021 Share Posted June 1, 2021 So much for not actually testing. PROCEDURE LineWeightChange; CONST { substitute these with the required values } newWeight = 0.13; {mm} VAR milWeight: Real; PROCEDURE ChangeIt (h : HANDLE); BEGIN SETLW(h, milWeight); END; BEGIN milWeight := newWeight * 1000 / 25.4; {convert mm to mils} FOREACHOBJECT(ChangeIt, T=2); {This selects lines only, not circles, polys, rectangles, etc.} END; RUN(LineWeightChange); Quote Link to comment
Pat Stanford Posted June 1, 2021 Share Posted June 1, 2021 PROCEDURE LineWeightChange; { © Petri Sakkinen 2008 } {modified 2021 to work on a range of line sizes} CONST { substitute these with the required values } oldWeight = 5; {in mil} newWeight = 79; {in mil} PROCEDURE ChangeIt (h : HANDLE); BEGIN SETLW(h, newWeight); END; BEGIN FOREACHOBJECT(ChangeIt, ((LW <= oldWeight+1) & (LW >= oldWeight-1))); {selects all objects with LW within 1 mil of OldWeight} END; RUN(LineWeightChange); Quote Link to comment
Tere Posted June 1, 2021 Author Share Posted June 1, 2021 Great, thanks, we are getting there! Here is what the 1st script did - changed some lines but left out others - some seem to be lines and some polylines, so I don't really know what could be happening there? Quote Link to comment
Pat Stanford Posted June 1, 2021 Share Posted June 1, 2021 If you need to change other object types rather than just lines, you will need to use the Criteria Editor to create a criteria to replace the T=2 portion of the following line. FOREACHOBJECT(ChangeIt, T=2); T=2 means objects of Type 2, which are lines. If you really want to change all the objects in the drawing, just select them all and change them using the attributes palette. Otherwise you need to learn about Criteria and how to edit them in the above script to select just the objects you want. The other issue you might be seeing is that the script as written only changes lines actually placed on a layer. Lines in symbols, groups, or PIOs are not effected. Quote Link to comment
Tere Posted June 1, 2021 Author Share Posted June 1, 2021 Thanks a lot, I will play around and see what I can do!! Quote Link to comment
Tere Posted June 2, 2021 Author Share Posted June 2, 2021 Just to let you know, I managed to resolve it by adding: FOREACHOBJECT(ChangeIt, T=POLY); after this line of the script: FOREACHOBJECT(ChangeIt, T=2); ...apparently, some of the lines were polygons, now it works fine! Thanks again for helping 🙂 Quote Link to comment
Pat Stanford Posted June 2, 2021 Share Posted June 2, 2021 So that change will fix the polygons only. To do both lines and polys in a single go use: FOREACHOBJECT(ChangeIt, ((T=POLY) & (T=2))); Welcome to the scripting club!! 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.