Jump to content
Developer Wiki and Function Reference Links ×

copy external geometry inside a PIO


Pi_

Recommended Posts

how can one import external geometry inside a PIO

GetPt(pt5.x,pt5.y);

h:= PickObject(pt5.x,pt5.y);

if ((gettype(h)=3) or (gettype(h)=4) or (gettype(h)=5) or gettype(h)=21)) then begin

h:=hduplicate(h,pt6.x-pt5.x,pt6.y-pt5.y);

pathHd:= SubtractPolygon(pathHd,h,0);

End;

Link to comment
how can one import external geometry inside a PIO

GetPt(pt5.x,pt5.y);

h:= PickObject(pt5.x,pt5.y);

if ((gettype(h)=3) or (gettype(h)=4) or (gettype(h)=5) or gettype(h)=21)) then begin

h:=hduplicate(h,pt6.x-pt5.x,pt6.y-pt5.y);

pathHd:= SubtractPolygon(pathHd,h,0);

End;

I thought GetPt only worked in tools ( could be wrong here )

Besides that its important to duplicate the path of the geomtry prior to using it, otherwise you'll break the original object.

Did you try the above script ?

Link to comment

Yes I tried, I also tried SetParent but this doesn't work anymore (since VW12.5)

this is how I succeeded to bring the geometry inside the PIO (GetPt works fine inside PIO!)

GetPt(pt5.x,pt5.y);

h:= PickObject(pt5.x,pt5.y);

getsymloc(pioHandle,pt6.x,pt6.y);

if ((gettype(h)=3) or (gettype(h)=4) or (gettype(h)=5) or gettype(h)=21)) then begin

h:=CreateDuplicateObject(h,pioHandle);

hmove(h,-pt6.x,-pt6.y);

pathHd:= GetCustomObjectPath(pioHandle);

pathHd:= hDuplicate(pathHd,0,0);

pathHd:= SubtractPolygon(pathHd,h,10);

ok:=SetCustomObjectPath(pioHandle,pathHd);

but now I'm stuck on "SubtractPolygon" it doesn't seem to work because I'm not getting back a handle (VW crashes on this code)

Link to comment
  • 3 weeks later...

You really shouldn't be using GetPt inside the object creation section of the PIO. what happens if you open a file and regenerate 100 instances of the PIO? Ideally, this would be part of a button event (there have been a number of posts on PIO buttons), which would copy the geometry into the object's path or profile group, where the object creation code can access it later. Any PIO can have a path or profile, even point objects. If you already have path and profile groups, you may have to manipulate your path before you bring it back in to the group.

In your case, you don't check to see if pathHd (the object's path) is NIL. If the object is new and doesn't have a path, this could be an issue.

-Josh

Link to comment
  • 10 months later...

Ciao,

I can't but insist. You should religiously check NIL handles and never run user interaction from the regen code of a plug-in. Let that run on demand only.

Didn't also SubtractPolygon output a group under circumstances? You should check for the validity of the path to be used for subtraction.

orso

{ run this only on click on a button }
{ on event 35 (kObjOnObjectUIButtonHit):  }
CASE theButton OF
cBut_DoThis :
   GetPt(pt5.x, pt5.y);
cBut_DoThat :
   h := PickObject(pt5.x, pt5.y); 
END;

{ run this on regenerating the plug-in }
{ on event 3 (kParametricRecalculate):  }
IF h <> NIL THEN BEGIN
   GetSymLoc(pioHandle, pt6.x, pt6.y);

   CASE GetType(h) OF
   3..5, 21:
       BEGIN
           h := CreateDuplicateObject(h, pioHandle);
           hmove(h, -pt6.x, -pt6.y);

           pathHd := GetCustomObjectPath(pioHandle);
           IF pathHd <> NIL THEN BEGIN
               pathHd := HDuplicate(pathHd, 0, 0);
               pathHd := SubtractPolygon(pathHd, h, 10); 

               IF SetCustomObjectPath(pioHandle, pathHd) THEN BEGIN
                   ...
               END;
           END; { pathHd <> NIL }
       END;
   END;
END; { h <> NIL }

GetPt(pt5.x,pt5.y);

h:= PickObject(pt5.x,pt5.y);

getsymloc(pioHandle,pt6.x,pt6.y);

if ((gettype(h)=3) or (gettype(h)=4) or (gettype(h)=5) or gettype(h)=21)) then begin

h:=CreateDuplicateObject(h,pioHandle);

hmove(h,-pt6.x,-pt6.y);

pathHd:= GetCustomObjectPath(pioHandle);

pathHd:= hDuplicate(pathHd,0,0);

pathHd:= SubtractPolygon(pathHd,h,10);

ok:=SetCustomObjectPath(pioHandle,pathHd)

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