Jump to content

Line Weight Change - troubleshooting line weight values setting


Tere

Recommended Posts

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! 

Screenshot 2021-06-01 at 19.27.20.png

Link to comment

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.

Link to comment

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!!

Link to comment
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);

 

Link to comment

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);

 

Link to comment
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);

 

Link to comment

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.

Link to comment

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 🙂

Link to comment

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.

Guest
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.

×
×
  • Create New...