Jump to content
Developer Wiki and Function Reference Links ×

VW Script for finding objects, and then moving them


Ajychau

Recommended Posts

Hello!

I've been thinking about writing a script that has the ability to automate the importing of consultant drawings and setting it up to our standards.

Essentially I have a survey drawing coming in and it may have multiple classes for the contours. We generally want to move those contours to a separate layer.

So the usual step would be:

  • Import DWG, with prefix 'X_SUR-' for all the classes.
  • Rename layer to 'X_Survey ACTIVE'.
  • Create layer 'X_Survey contours'.
  • Go to any class that might be 'X_SUR-contours major' or 'X_SUR-cont maj' or 'X_SUR-cont min' etc.
  • Turn class options to 'Show/Snap'
  • Select all
  • Copy and then Paste in place in 'X_Survey contours' layer

This is what I've written:

PROCEDURE MoveObjClass;

VAR

LayBase, Lay1, className, Cs1, Cs1a: STRING;
i, n: INTEGER;

BEGIN
LayBase:=Concat('X_Survey ACTIVE');
Lay1:=Concat('X_Survey Contour');
Layer(LayBase);
SetLayerOptions(4);
cs1:=('X_SUR-cont*');
FOR i := 3 TO CLASSNUM DO BEGIN
className:=CLASSLIST(i);
n:=POS(Cs1,className);
IF (n=1) THEN BEGIN
	ShowClass(Cs1);
	SetClassOptions(5);
	ReDrawALL;
	SelectALL;
	DoMenuTextByName('Cut',0);
	Layer(Lay1);
	DoMenuTextByName('Paste In Place',0);
	END;
END;
END;

RUN(MoveObjClass);

It's a bit of a frankenstein peice of code...but I don't know if I'm heading down the right path, and I don't know how to get it to select the classes it finds with "X_SUR-cont"

Any help would be much appreciated!!

Happy Easter!

Link to comment

I'm not sure why you are using the concat function in the beginning, if you don't have to create a string from multiple strings/variables you can just define it as a string:

LayBase:='X_Survey ACTIVE';
Lay1:='X_Survey Contour';

You need to do this in another way.. You script above will select all objects in that layer at once but you need to have them selected each one by one.

What about this:

- You go manually to the imported layer

- You allready created that extra layer / script it

- Trough script, you can load the current active layer and use that as search criteria to load all the drawn objects on it. Foreachobject(Checkclasses,criteria)

- in this foreachloop you pass each object and load its class and compare your actions, edit the class options of that object and move/copy it to any layer you want.

and I don't know how to get it to select the classes it finds with "X_SUR-cont"

IF Pos('X_SUR-cont',classname) > 0 THEN BEGIN
END;

Edited by hippothamus
Link to comment

Hey Hippothamus,

Thanks for the reply,

I'll have another look at it. I was attempting to select all the objects on a specific class and then move it to a new layer. Then it needs to revert back to the original import layer and find a different class.

I'll try out the Foreachobject command and see if that works, and I guess I'll build a script for each class first and then try combining it into a master script...

Cheers!

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