Jump to content
Developer Wiki and Function Reference Links ×

Symbol Library Script


markdd

Recommended Posts

Hi

I want to spend a little time updating and rationalising my symbol libraries which are contained in various folders within one drawing.

What I really want to do is streamline my work with regard to use of pen colours. Currently I have over 70 colours in this file and I would like to get that down to just Black and White (for now). Many of my symbols have multiple classes and I need to keep it that way. I have looked into the "Change Symbol Attributes" menu command but this is too general. Is there another way that I could change all the pen and fill colours in all the symbols in my library to Black pen, White fill without editing every symbol (over 800!) I am wondering if anyone out there has written a script to do this.

Any thoughts would be greatly appreciated!

Mark

Link to comment

Raymond

All colours are meant to be set by class. I had hoped that by simply changing all the classes to Black Pen, White Fill that that would sort out the issue. Sadly not. It appears that colours seem to be embedded in groups of objects within symbols etc and all sorts of other things besides. A bit of a mess really! Many of the symbols have history back to when I was a novice VW user (2005). Now that I am a little "wiser" I am trying to weed out old stuff and be more productive!

Mark

Link to comment

So, it seems not all objects are set to have their attributes to "Set by Class". If you have your classes set the way you like them, then all you need is a script to set all objects to "attributes by class". Do you want ALL attributes controlled by class, or just the color attributes?

Raymond

Edited by MullinRJ
Link to comment

Hi

It's the colour that is set by class. Despite the fact that all the objects in the file look and say that they are all the same colour, when I look at the colour palette for the file I have over 60 or so colours in the file. I have "purged all the unused colours" and still am left with just about the same number. What I want to do is totally eradicate all of the colours apart from Black and White from the document!

The reason for this is to stop bringing in random colours into new documents when using my symbol library. I am sure this has occurred because symbols have been created over 10 years or so. It would be great to have a delete all pen colours and replace with Black and delete all fill colours and replace with white. Is such a script possible in vectorworks? Essentially I am doing some Spring cleaning!

Thanks for your help!

Mark

Link to comment

Mark,

   This should do what you described. Make sure you try it on a test file first.

PROCEDURE MakeAllBW;
{ Set ALL Class Colours to B&W. }
{ Set ALL objects in symbols to accept colour attributes by class. }
{ 21 Mar 2016 - Raymond J Mullin }

{ ***** ALWAYS use this script on a    COPY   of your data! ***** }

VAR
I :Integer;
ClassName :String;

function SetColourByClass(H :Handle) :Boolean;
{ Set Fill and Pen Colours to be "ByClass". }
Begin
	SetFillColorByClass(H);
	SetPenColorByClass(H);
End;		{ SetColourByClass }


BEGIN
{ Change colour attributes of all classes to use Black & White. }
for I := 1 to ClassNum do begin
	ClassName := ClassList(I);
	SetClFillFore(ClassName, 0, 0, 0);    { black }
	SetClFillBack(ClassName, 65535, 65535, 65535);    { white }
	SetClPenFore(ClassName, 0, 0, 0);    { black }
	SetClPenBack(ClassName, 65535, 65535, 65535);    { white }
end;		{ for }

{ Change all objects in Symbol Defs to accept colour attributes "By Class" }
ForEachObjectInList(SetColourByClass, 0, 2, FSymDef);    { 0=All objects, 2=Deep }

SysBeep;		{ sound off when done }
END;
Run(MakeAllBW);

All the best,

Raymond

Edited by MullinRJ
Link to comment

Hello Mark,

   Looking at your file's resources I was able to find the 41 colors you cannot delete. I selectively deleted groups of resources and purged the colors after each deletion. When the total color count dropped I knew there were color assignments in that batch of resources. I closed the file without saving and reopened it, looking more closely at individual resources.

   One of the colors (Center Line Red) is in your hatch "Unused Lights ". I assume you want to keep this.

   Three colors are in your Line Types, "RGB" and "RGBW". Check the geometry. I assume you want to keep these as well.

   The rest are in the objects of your symbols.

   I got the count down to 23, minus the four colors mentioned above, leaving 19 in your symbol library. I am not sure where these reside, defined inside PIO's or set in a PIO's instance, perhaps. You may have better insight than I.

   When you set an object to use class colors, the object still retains its original colors. I modified the script above to remove individual object colors in addition to setting all symbol objects to use class colors. It should be possible to search for objects using non-B&W colors. If you'd like to pursue that avenue, please contact me offline.

   I hope this gets you back on track.

PROCEDURE MakeAllBW;
{ Set ALL Class Colours to B&W. }
{ Set ALL objects in symbols to accept colour attributes by class. }
{ 21 Mar 2016 - Raymond J Mullin }
{ 						Updated to also set symbol objects to B&W for their default colours. }

{ ***** ALWAYS use this script on a    COPY   of your data! ***** }

VAR
I :Integer;
ClassName :String;

function SetColourByClass(H :Handle) :Boolean;
{ Set Fill and Pen Colours to be "ByClass", and reset each object's default colours to B&W. }
Begin
	{ Set each object's default colours to B&W. }
	SetFillFore(H, 0, 0, 0);    { black }
	SetFillBack(H, 65535, 65535, 65535);     { white }
	SetPenFore(H, 0, 0, 0);   { black }
	SetPenBack(H, 65535, 65535, 65535);   { white }

	{ Set each object to use class colours. }
	SetFillColorByClass(H);
	SetPenColorByClass(H);
End;		{ SetColourByClass }


BEGIN
{ Change colour attributes of all classes to use Black & White. }
for I := 1 to ClassNum do begin
	ClassName := ClassList(I);
	SetClFillFore(ClassName, 0, 0, 0);    { black }
	SetClFillBack(ClassName, 65535, 65535, 65535);    { white }
	SetClPenFore(ClassName, 0, 0, 0);   { black }
	SetClPenBack(ClassName, 65535, 65535, 65535);   { white }
end;		{ for }

{ Change all objects in Symbol Defs to accept colour attributes "By Class" }
ForEachObjectInList(SetColourByClass, 0, 2, FSymDef);    { 0=All objects, 2=Deep }

SysBeep;		{ sound off when done }
END;
Run(MakeAllBW);

All the best,

Raymond

Link to comment
  • 6 years later...
On 3/19/2016 at 5:03 PM, MullinRJ said:

Are you setting your colors by class, or individual object attributes? A script would be pretty easy, but one needs to know which set of colors to change.

Raymond

Hi Raymond,

 

What if i need individual object, not changing color by class. Could not locate a right fuction to Traver objects inside lighting symbol geometry. Seems like EACHOBJECTINLIST doesn't wotk, anything I am missing?

 

Thank you in advance

Link to comment

I would start with H := FIn3D(ObjHand); and then use variable H to step through the object's components. But if the container object is a PIO, any changes you make to objects inside will be discarded the next time the PIO regenerates. If the container object is a Symbol, then any change you make inside the symbol will show up in every instance of that symbol in the drawing. If you explain more of what you are trying to achieve, I or someone else, can better explain how to proceed.

 

Raymond

 

  • Like 1
Link to comment

I am trying to get handles for lable legend components , I would love to adjust lable legend's positions by exact value if that is possible. For instance, move CHANNEL NUMBER +5" from its current position.  

 

For fun, I did try H: = FIn3D(H) to change objects attributes inside PIO, it does get  discard when reset objects. Learned from @Jesse Cogswell I could use FInGroup to travers throught objects inside PIO

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