Jump to content

Changling objects on a class/layer


Recommended Posts

Hi everyone, 

 

I would like to be able to write scripts that change objects on a given layer/class. I will want to do things like: changing fill or pen colour/thickness or switching a particular layer/class off. Can you please advise me whether there is a good example of a similar script out there that I could have a look at and use as a guideline when adjusting to fit my needs?

 

Thank you very much!!

Link to comment

Here is a very basic script that will give you an outline of what you need to do.

 

The key to this is the ForEachObject line. ForEachObject passes each object that matches the criteria (the second parameter in this case  that the Class is 'Dimension') to the procedure that is the first parameter (in this case Execute).

 

Inside the execute procedure, Hd1 is a Handle (Pointer) to the object currently being passes to the procedure. You can use it as I do in this example, or you can use it to get more information about the object and then decide what you want to do with that specific object, (ie change it, leave it alone, delete it, etc.).

 

You an put as many different commands in the Execute procedure as you need. So you could change the PenFore, FillFore, and Lineweight all in the same procedure.

 

Ask again as you need more information.

 

 

 

Procedure Change;

Var
	NewPenColorR, NewPenColorG, NewPenColorB:	LongInt;
	
Procedure Execute(Hd1:Handle);
	Begin
		SetPenFore(Hd1, NewPenColorR, NewPenColorG, NewPenColorB);
	End;
	
Begin
	NewPenColorR:= 65535;
	NewPenColorG:= 160;
	NewPenColorB:= 160;
	
	ForEachObject(Execute, ((C='Dimension')));
	RedrawAll;
End;

Run(Change);

 

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