Jump to content
Developer Wiki and Function Reference Links ×

Script to convert selected objects to PIOs?


VvierA

Recommended Posts

Hello,

again a question for the great members of this forum.

I already mentioned, that I managed to program a custom space tool.

It's a custom 2d path object with an 'integrated' symbol.

Now I was wondering, if it's possible to convert existing polygons or polylines or rectangles to my custom space tool.

But can't figure out how to do that. It should work like this:

Select objects, and call the new 'convert tool'.

I tried something like this:

BEGIN

h:=FSActLayer;

WHILE (h <> NIL) DO BEGIN

{at this place follows the code that I used to generate the custom space tool}

END;

h:=NextSObj(h);

END;

And I tried this code as a Menu command and as a Tool and I entered all the parameters that are needed.

But it doesn't work.

Problem Nr. 1

If I use the code as a menu command, I do not now how to access or enter the parameters on runtime.

Problem Nr. 2

The code does not generate PIOs. It generates separated symbols and polylines.

Problem Nr. 3

The code does not stop. It generates thousands of polylines and symbols of the selected object.

Maybe anyone has an idea for a better approach?

Maybe there is a sample script for converting selected objects in PIOs?

Thank you

VvierA

Link to comment

Hello Carl,

???To make your script stop, you need to put the NextSObj() command inside the WHILE loop, as such:

BEGIN

???h:=FSActLayer;

???WHILE (h <> NIL) DO BEGIN

??????{at this place follows the code that I used to generate the custom space tool}

??????h:=NextSObj(h);

???END;

END;

HTH,

Raymond

Link to comment

I followed all the tips and everything works fine, except...

the script converts ONLY the first selected object.

Strange enough because if I replace the line

newobjH := CreateCustomObjectPath('custom2dpathobject', objectH, nil);

by

SetPenFore(objectH,45);

the script converts every selected object to a red pen color.

So it works with a simple change of the pen color but it does not work to convert all selected objects to my custom 2d path object.

Does anybody have a hint?

VvierA

--------------

PROCEDURE converter;

VAR

objectH, newobjH :HANDLE;

BEGIN

objectH := FSActLayer;

WHILE (objectH <> NIL) DO BEGIN

message((GetType(objectH)));

IF (GetType(objectH) = 3) OR

(GetType(objectH) = 4) OR

(GetType(objectH) = 5) OR

(GetType(objectH) = 6) OR

(GetType(objectH) = 21) THEN BEGIN

newobjH := CreateCustomObjectPath('custom2dpathobject', objectH, nil);

END;

objectH := NextSObj(objectH);

END;

END;

run(converter);

Link to comment

Maybe the object (objectH) get's deleted because of the CreateCustomObjectPath? Therefore, the handle will not exist and NextSObj(objectH) will give NIL. Loop through the objects to create an array first, then loop the array to do the conversion. Or you can loop them backwards, first getting the previous, then converting the current for doing it in one loop.

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