Pi_ Posted June 25, 2014 Share Posted June 25, 2014 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; Quote Link to comment
Hippocode Posted June 25, 2014 Share Posted June 25, 2014 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 ? Quote Link to comment
Pi_ Posted June 25, 2014 Author Share Posted June 25, 2014 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) Quote Link to comment
JBenghiat Posted July 16, 2014 Share Posted July 16, 2014 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 Quote Link to comment
_c_ Posted May 19, 2015 Share Posted May 19, 2015 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) 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.