Jump to content
Sign in to follow this  
The Hamma

Script wont run in symbol

Recommended Posts

I have written a script to change the lineweights of objects in a drawing based on there existing lineweight and it works fine in a layer but I can not get it to work in a symbol. Does anyone know what I could do to make this work. One Idea I have is to cut the objects out of the symbol and place them on a layer make the change and then put them back in the symbol but I do not know how do do this in a script.

my script is below.

Procedure Lineweight;

Label 100, 101, 102, 103, 104, 105, 106;

VAR

H1 : HANDLE;

P1,P2 : real;

Begin;

DSelectAll;

SelectObj(INSYMBOL & INOBJECT & INVIEWPORT & (LW=7));

DSelectObj(INSYMBOL & INVIEWPORT & (T=TEXT));

H1:= FSActLayer;

100:SetLW(H1,3);

H1:=NextSObj(H1);

if H1<>Nil then goto 100;

DSelectAll;

SelectObj(INSYMBOL & INOBJECT & INVIEWPORT & (LW=10));

DSelectObj(INSYMBOL & INVIEWPORT & (T=TEXT));

H1:= FSActLayer;

101:SetLW(H1,4);

if H1<>Nil then goto 101;

DSelectAll;

SelectObj(INSYMBOL & INOBJECT & INVIEWPORT & (LW=14));

DSelectObj(INSYMBOL & INVIEWPORT & (T=TEXT));

H1:= FSActLayer;

102:SetLW(H1,6);

H1:=NextSObj(H1);

if H1<>Nil then goto 102;

DSelectAll;

SelectObj(INSYMBOL & INOBJECT & INVIEWPORT & (LW=20));

DSelectObj(INSYMBOL & INVIEWPORT & (T=TEXT));

H1:= FSActLayer;

103:SetLW(H1,8);

H1:=NextSObj(H1);

if H1<>Nil then goto 103;

DSelectAll;

SelectObj(INSYMBOL & INOBJECT & INVIEWPORT & (LW=28));

DSelectObj(INSYMBOL & INVIEWPORT & (T=TEXT));

H1:= FSActLayer;

104:SetLW(H1,11);

H1:=NextSObj(H1);

if H1<>Nil then goto 104;

DSelectAll;

SelectObj(INSYMBOL & INOBJECT & INVIEWPORT & (LW=39));

DSelectObj(INSYMBOL & INVIEWPORT & (T=TEXT));

H1:= FSActLayer;

105:SetLW(H1,12);

H1:=NextSObj(H1);

if H1<>Nil then goto 105;

End;

Run (Lineweight);

Share this post


Link to post

Are you trying to change the lineweights in the document or just the active layer?

Using ForEachObject would be a better approach since symbols cannot be selected based on the lineweight. By definition, symbols are container objects that do not have a lineweight and act more like an image.

Share this post


Link to post

Since I did not need to keep the symbols as symbols I was able to convert them to groups and then my revised script worked for the entire drawing. Thanks for the input.

PROCEDURE SelectedObjLineWeight;

Var

cw:integer;

FUNCTION explodeob(h:HANDLE) :BOOLEAN;

BEGIN

SymbolToGroup(h,2);

END;

FUNCTION edObject(h:HANDLE) :BOOLEAN;

BEGIN

cw:=GetLW(h);

if cw = 1 then SetLW(h, 8);

if cw = 7 then SetLW(h, 4);

if cw = 10 then SetLW(h, 6);

if cw = 14 then SetLW(h, 8);

if cw = 20 then SetLW(h, 11);

if cw = 28 then SetLW(h, 12);

if cw = 39 then SetLW(h, 15);

END;

BEGIN

DSelectAll; SelectObj(INSYMBOL & INVIEWPORT & (T=Symbol));

ForEachObjectInLayer(explodeob, 2, 2,1);

ForEachObjectInLayer(edObject, 0, 2,1);

END;

Run(SelectedObjLineWeight);

Share this post


Link to post

You can leave this line out cause the selection status isn't important.

DSelectAll; SelectObj(INSYMBOL & INVIEWPORT & (T=Symbol));

Why don't you use ForEachObject like Miguel suggested? That way you don't need to convert your symbols to groups...

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...