VvierA Posted October 21, 2012 Share Posted October 21, 2012 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 Quote Link to comment
Dieter @ DWorks Posted October 22, 2012 Share Posted October 22, 2012 There is a command for that! I don't know the exact name in english, but I think it's 'Objects by poly'. You have to add your pio in the texts of this command to let it show up in the list of path pio's to convert the objects to. Quote Link to comment
VvierA Posted October 22, 2012 Author Share Posted October 22, 2012 @DWorks Thank you I didn't find the command yet. Do you happen to know the french or german name? Maybe I can find it this way or maybe some other forum member can identify it? Quote Link to comment
MullinRJ Posted October 22, 2012 Share Posted October 22, 2012 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 Quote Link to comment
VvierA Posted October 22, 2012 Author Share Posted October 22, 2012 Hello Raymond, thank you. That's it, the loop works now. Maybe another idea about how to convert something into a custom 2d path PIO? VvierA Quote Link to comment
Dieter @ DWorks Posted October 22, 2012 Share Posted October 22, 2012 Do you happen to know the french or german name? Dutch: Objecten dmv polylijn. Quote Link to comment
VvierA Posted October 28, 2012 Author Share Posted October 28, 2012 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); Quote Link to comment
Dieter @ DWorks Posted October 29, 2012 Share Posted October 29, 2012 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. Quote Link to comment
VvierA Posted October 29, 2012 Author Share Posted October 29, 2012 Ok. Great. Thank you. I did this (2 loops, array of handles) and now it works. Quote Link to comment
Recommended Posts
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.