michaelk Posted July 29, 2019 Share Posted July 29, 2019 How do you assign an object to a control point? Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 Wow. MoveTo(ControlPoint01X,ControlPoint01Y); works! Amended question: Can I give ControlPoint01X and Y a default value relative to the control geometry of a parametric object? Quote Link to comment
Pat Stanford Posted July 29, 2019 Share Posted July 29, 2019 I thought that all references to the control points were within the internal PIO coordinate system. But I am probably wrong. If I am wrong, you should be able to use the GetCustomObjectInfo to find the insertion point of the object and then set the control point offsets from there. 1 Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 Pat If you do MoveTo(ControlPoint01X,ControlPoint01Y); the object appears at the 0,0 of the control object. But what if I want it someplace else relative to the control object? I'm assuming if I write an offset from that it will regenerate to that offset even after the user moves the control point. But I'm not sure. Quote Link to comment
Peter Vandewalle Posted July 29, 2019 Share Posted July 29, 2019 MoveTo(ControlPoint01X + <X-value>,ControlPoint01Y +<Y-value>) should work. ControlPoint01X and ControlPointY01 are considered coordinates from the PIO origin. So they are just reals. 1 Quote Link to comment
Sam Jones Posted July 29, 2019 Share Posted July 29, 2019 In other words add the insertion point X,Y to the control point X,Y. 1 Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 But when you do that the object is offset from the control point. I'm looking for a way to do what the window and door tools do. The label is not at 0,0 and the control point is in the middle of the label. Quote Link to comment
Pat Stanford Posted July 29, 2019 Share Posted July 29, 2019 ControlPoint01X:=ControlPoint01X+Blah; ControlPoint01Y:=ControlPoint01Y-Fargh; Then insert text at the new control points. Completely untested. VW not even running right now. 1 Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 5 minutes ago, Pat Stanford said: Completely untested. VW not even running right now. 😀 But the control point is a parameter of the tool. If I understand correctly you can't assign a value to it in the script, you would have to write it to a record field. I guess what I'm asking is how does the door label get offset from the insertion point of the door by default and the door label appears to be centered on the control point? Quote Link to comment
Pat Stanford Posted July 29, 2019 Share Posted July 29, 2019 So maybe it is SetRField(MyObjectHandle,MyPIOName,'ControlPointO1X',Concat(ControlPoint01X+Blah)); I know i have moved he control point inside a script before. I just can't remember where or even what name to search under. Sorry. 1 Quote Link to comment
Sam Jones Posted July 29, 2019 Share Posted July 29, 2019 I don't think you can assign control point values to a tool, because there is no object instance, but I have never tried. I move the control points of PIO objects all the time. OffsetX := 10; OffSetY := 5; GetSymLoc(theObject, ObjX, ObjY) SetRField(theObject, 'TheObjectPIOName', 'ControlPoint01X', ObjX + OffsetX) SetRField(theObject, 'TheObjectPIOName', 'ControlPoint01Y', ObjY + OffsetY) 1 Quote Link to comment
JBenghiat Posted July 29, 2019 Share Posted July 29, 2019 Is the object you are trying to relate to the control point part of the custom object with the control point or a second object that you are relating in a parent/child relationship? In general, there is nothing special about a control point: think of it as a dimension field measuring from the origin (insertion point) of the PIO. The only difference is that in addition to manually typing a value in the OIP, the user can set those distance values via clicking on the drawing. 1 Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 In this example I have a custom path object. I'd like to place labels offset from the beginning and end of the path object.. I've never used control points before and just discovered that MoveTo(ControlPoint01X,ControlPoint01Y); before creating the text object works. I didn't realize - and probably don't fully understand yet - that you should write the offset to the record. Doing the math in the MoveTo function puts the label in the correct place, but makes the labels not coincident with the control point. Quote Link to comment
Pat Stanford Posted July 29, 2019 Share Posted July 29, 2019 So just use the SetRField to set the control point to be where you want the label and then use the control points to set the location of the text. But actually that might not work. I seem to remember that setting values to parameters are not stored until the end of the PIO execution. So you probably need to read the original control points into variables and then modify the variables to get the location to write the text and to also set the control point values before the end of the PIO. 1 Quote Link to comment
Sam Jones Posted July 29, 2019 Share Posted July 29, 2019 Do you want the labels to be part of the object ? If yes, then: (I do the following with cable objects all the time.) Do you want the user to be able to change the location of the label based on the user moving the control point? If not, forget about the control point and write the place at the location of the first vertex and the last vertex. If so, on creation, set the control points to the location of the first vertex and the last vertex, and from then on always place the text at the location of the control points. GetRField(theObj, theObjPIOName, 'ControlPoint01X'). If no, then: (I do the following with Truss Labels all the time); just find the location of the path object vertices and write the labels to those locations. 1 Quote Link to comment
JBenghiat Posted July 29, 2019 Share Posted July 29, 2019 I'm still not clear if the text blocks are part of the path object or separate objects on top of the path object. I'm also not sure about your scenario: you say that you're inserting text at the control point, but that the control point needs to be moved to the text (?). Or are you trying to set the label center to a default location on insertion that is based on the object's geometry? 1 Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 Thanks, Sam. I'll try that. Josh, I'm trying to place 2 text labels with control points so the user can adjust. One is offset -xx,yy from the beginning of the custom path object and one is offset xx,yy from the end of the custom path object. So the second option. A default location based on the object's geometry. Quote Link to comment
Sam Jones Posted July 29, 2019 Share Posted July 29, 2019 Using the second option the labels will not move when the path object is moved or edited, but it will place the labels at the beginning and end and allow the user to adjust the location of the labels to any place they wish. 1 Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 Thanks, Sam. It's perfectly fine if they don't move with the object. There are options for 2 other labels and I want to avoid a pile of labels at the object 0,0. 🙂 Quote Link to comment
JBenghiat Posted July 29, 2019 Share Posted July 29, 2019 So, do I assume correctly that the labels are part of the object? You're going to want to define four dimension parameters to display the object. Hide the control point fields from the user in the OIP. The real work comes with enabling state events for your object and parsing them in the reset event. If the object is created: use PointAlongPoly() to find initial control point values and write them to both the control point and the offset fields. Label 1, the control point = the offset. Label 2, the control point = the coordinate of the endpoint + the offset. If the user has edited one of the offset fields: calculate the control point and write to field. Just treat the control point field like any other distance field. If the user has edited one of the control point fields: calculate the offsets and write to the offset fields. 1 Quote Link to comment
michaelk Posted July 29, 2019 Author Share Posted July 29, 2019 Thanks Joshua. Wish I didn't have to work right now so I could try all this out! Quote Link to comment
Sam Jones Posted July 29, 2019 Share Posted July 29, 2019 So it would seem that the trick for you is to get a handle to the path of the path object. For a path object: your first vertex will be (0,0) so just add the offset to that (negative numbers to move left or down). your last vertex will be Get NumVertices:= GetVertNum(PathHd); GetPolyPt(PathHd,NumVertices,LastVertX, LastVertY); add the offset to that (negative numbers to move left or down). Quote Link to comment
michaelk Posted September 19, 2019 Author Share Posted September 19, 2019 OK. I think part of my confusion is whenever I change anything in the definition of the control point it adds an extra Y to the name of the y control point. Is this a known issue? I was never able to get GetRField do some math SetRfield MoveTo BeginText … to work. But just doing the math and doing a MoveTo works. Edit: I'm wrong doing the math results in handles that are offset from the labels. Quote Link to comment
michaelk Posted September 19, 2019 Author Share Posted September 19, 2019 I'm trying to write a tool the puts Begin Here at the beginning of the control polyline and End Here at the end of the polyline. Any help on where to put the GetRField and SetRField would be MUCH appreciated. The math I'm doing doesn't work.😖 PS. the 1" offset from the beginning and end of the polyline are because it often returns an incorrect tangent at the ends. Quote Procedure Test; VAR SeatNumH, ObjectHandle, tempHandle, ControlGeometry, objectHand, recordHand, wallHand : HANDLE; XCordOffset, YCordOffset, Rx,Ry, ControlLength : REAL; BTest : BOOLEAN; PtAlongPath, TangentAtPoint : VECTOR; Sx,Sy, objectName, CurrentClass : STRING; Pt : POINT; BEGIN CurrentClass := ActiveClass; BTest := GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand); ControlGeometry := GetCustomObjectPath(objectHand); ControlLength := HLength(ControlGeometry); BTest := PointAlongPoly(ControlGeometry,1", PtAlongPath,TangentAtPoint); MoveTo(pControlPoint01X-24,pControlPoint01YY-24); BeginText; 'BEGIN HERE' EndText; SetTextVerticalAlign(LNewObj,3); SetTextJust(LNewObj,2); SetPenColorByClass(LNewObj); SetFPatByClass(LNewObj); SetFillColorByClass(LNewObj); SetTextStyleByClass(LNewObj); BTest := PointAlongPoly(ControlGeometry,ControlLength - 1", PtAlongPath,TangentAtPoint); Sx:=GetRField(objectHand, 'BeginningAndEnd', 'pControlPoint02X'); Rx := Str2Num(Sx); Sy:=GetRField(objectHand, 'BeginningAndEnd', 'pControlPoint02YY'); Ry := Str2Num(Sy); MoveTo(pControlPoint02X+PtAlongPath.x+24,pControlPoint02YY+PtAlongPath.y+24); BeginText; 'END HERE' EndText; SetTextVerticalAlign(LNewObj,3); SetTextJust(LNewObj,2); SetPenColorByClass(LNewObj); SetFPatByClass(LNewObj); SetFillColorByClass(LNewObj); SetTextStyleByClass(LNewObj); END; RUN(Test); Quote Link to comment
James Russell Posted September 19, 2019 Share Posted September 19, 2019 (edited) Hmmm. This doesn't happen for me - just the one Y. Made a second Control Point set and they labelled as expected; 'ControlPoint02X' and 'ControlPoint02Y' I've just finished battling Control Points for one of my recent scripts. Snippets attached below (where relevant) - I can send you the full script via email if you need to break it apart (few relations would have to be made for forum posting!). But never had to write back to the control points... ------ cpx,cpy,ctx,cty,control_round :REAL; {Collection of Control Points} ----- cpx := PControlPoint01X; cpy := PControlPoint01Y; control_round := PControl_Round; ----- {Creating the Control Point Box and Text} IF show_title OR show_descr OR show_cat = TRUE THEN BEGIN { set the text properties } TextSize(10); TextRotate(0); TextJust(2); TextVerticalAlign(1); TextOrigin(cpx,cpy); label_concat:= ''; IF show_title = TRUE THEN BEGIN label_concat:= Concat(label_concat,title_descr,CHR(13)); end; IF show_descr = TRUE THEN BEGIN label_concat:= Concat(label_concat,body_descr,CHR(13)); end; IF show_cat = TRUE THEN BEGIN label_concat:= Concat(label_concat,category_descr,CHR(13)); end; CreateText(label_concat); cptext := LNewObj; { get the bounding box of the text } GetBBox(LNewObj,t1x,t1y,t2x,t2y); RRect(t1x-control_round,t1y+control_round,t2x+control_round,t2y-control_round,control_round,control_round); HMoveForward(cptext,TRUE); {message(Concat(t1x,' ',t1y,' ',t2x,' ',t2y));} END; ------ It's dirty but seems to work for me and my floating info box. #SorryNotSorry (bad codes are what I do!) J Edited September 19, 2019 by James Russell Wrote this in-between your posts! 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.