Jump to content
Developer Wiki and Function Reference Links ×

control point


hong

Recommended Posts

O.K. I am writing a script for a plug-in object with a control point in it. I can move a control point by 'SetRfield' to the place where I want when the script is executed. However this control point is locked, that is I can not drag around anymore. Is there a way to release this?

What I am trying to do is somewhat similiar to the tag in 'space' tool.

Link to comment

quote:

Originally posted by hong:

O.K. I am writing a script for a plug-in object with a control point in it. I can move a control point by 'SetRfield' to the place where I want when the script is executed. However this control point is locked, that is I can not drag around anymore. Is there a way to release this?

What I am trying to do is somewhat similiar to the tag in 'space' tool.

Hi,

If you want just to set a default initial value, use the parameter default field at the parameters panel inside the create plug-in panel.

Otherwise (if you depend on a calculation to set the control point) you have to create a condition so the SetRField wont be done at every objet regeneration/redraw.

For example you could use something like IsNewCustomObject() to set the control point only when the object is first inserted.

IF GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand) AND IsNewCustomObject(objectName) THEN

HTH

Alexandre

PS: Just curious, what is the plug-in you are creating?

Link to comment

Thanks for your replay.

What I am trying to create is a detail marker which doesn't come with VW. This marker consists of one rounded rectangle and a tag which should be able to move around outside of rectangle with a line that connects to the rectangle. (this part is similiar to space tool).

Now I can make my PIO to draw rectangle and write a tag starting from a control point so that it can be moved around after pio insertion. But I can not set the initial location of control point. Let say I want it be top right hand corner of rectangle. When I insert this pio, the control point alwary locates the first clicked point. When I use 'serRfiled', the control point goes to whereever I assign to but I can not move it anymore.

If I resove this as you suggest with 'Isnewcustomobject', my next question is how to get a point along my rectange near to the tag (control point if I make it work) in order to draw a line. I was testing 'getclosetpt', but this one only, I think, recognizes a vertice not any point.

Link to comment

Hong

As Alex said,you should be able to set the initial position of control point by editing the default setting.Hit the "parameters" button in the plug-in editor.This value is relative to the insertion point,so if you have defaults of 0X and 0Y your control will always be at the click.

If your script is setting the position of the control then it can't be changed without changing the script.In this case you'll be able to drag it but it will snap back to the scripted location.Is this what you mean by "locked"?

It seems to me that you should be able to get what you need fairly easily.Trouble is I'm not familiar with the space tool so it's not that clear to me what you're trying to do.How is your rounded rect drawn?Does it need to change size and have the control move accordingly?

If this doesn't help,you might want to post some or all of your script.

HTH

Charles

[ 08-30-2004, 11:30 PM: Message edited by: ccroft ]

Link to comment

Thanks for your reply.

I am using a rectanglar pio with one control point. RR is drawn by linelength and boxwidth and resizable afterward by selection handles. A control point will be inserted at the same time in an assigned location.

This location of control point is relative to the size of Rounded Rectangle when first inserted. In other word, it depends on the values of 'linelength' and 'boxwidth' initially. After first insertion, It can be dragged to a new position.

When I used 'SetRfield' for the control point record field, this sets the point permanently as you know unless I move RR and then it rewrites this value according to new linelength and boxwidth.

Following Alex's suggestion, I tested to use 'If IsNewCustomObject then' in order to set an initial value of control point. Interestingly, the readings from 'linelength' and 'boxwidth' doesn't go under this statement. I can assgin a numerical value such as '20"' but the parameter values such as 'linelength' and 'boxwidth' will not return to 'SetRfiled' after 'if IsNewCustomObject'.

Link to comment

Hong,

I am not sure if this is pertinent, but I have deduced some behavior in programming PIO's that I recently found confusing and undocumented.

The pParameters of the PIO act as constants during the execution of the PIO code (i.e., you cannot write to them). Though you can write to the record where they are stored with SetRField(), the new values you place in the record are not available to you until the next time the code is executed. I believe all the PIO pParameters are copied to memory before the script executes and are not updated again until the script is reexecuted (from moving, resizing or changing the PIO parameters in the OIP). When you reference a pParameter, you are not getting the value from the record, you are getting it from the copy that was made before the start of your script.

Since you probably want to access your values as they change within the script, don't access the pParameters directly. Copy them all to temporary values (script variables) at the start of your script and work with those (same technique they use). You can update the PIO record at any time, but also update your temporary variable and always work with it.

This caused me several hours of head scratching one day until I sorted it out.

HTH,

Raymond

Link to comment

Start to make a little bit of sense. Thanks Raymond.

However, I am still suspicious of this 'IsNewCustomObject(objectname)' statement. I did copy script variables from pParameter and when these variables are called after the 'IsNewCustomObject', they go back to default value of pParameter instead of the scrpit variables which stores current values. I am thinking, as you suggested, that the statement itself seems to be calling pParameter by nature. p2x and p2y below takes default value of linelength and boxwidth.

Begin

result:=GetCustomObjectInfo(objname, oh, rh, wh);

If result then

begin

boxW:= PBOXWIDTH;

boxL := PLINELENGTH;

p1x:=0;

p1y:=(-boxW/2);

p2x:=boxL;

p2y:=(boxW/2);

x:=Pcontrolpoint01X;

y:=Pcontrolpoint01Y;

PenSize(14);

PenPat(-2);

RRect(p1x,p1y,p2x,p2y,Pradius,pradius);

Rang:=GetSymRot(oh);

Drawtext;

Moveto(x,y);

Lineto(p2x,p2y-(pradius/2));

If IsNewCustomObject(objname) then

begin

SetRfield(oh, Getname(rh), 'CONTROLPOINT01X', Num2StrF(p2x));

SetRfield(oh, Getname(rh), 'CONTROLPOINT01Y', Num2StrF(p2y));

end;

end;

End;

Link to comment

So the problem is that you can't set a control point position based on the rrect.Just thinking out loud here..... How bout you test for IsNew at the top.If is new the rrect is drawn based on an offset from the control pt.If not New you draw the rrect based on params other than the control pt.

I would think that would give you a default rect that could be resized and a tag that could be moved independantly,tho it wouldn't maintain it's relationship to the rect automatically as the rect is resized.

Maybe not such a great solution....

Maybe it will give you another idea.

Good discussion

Charles

Link to comment

Well, I tested 'IsNew' upfront and it didn't work.

For some reason, I see my script running twice. I was inserting 'Alrtdialog' in few places to check the value of 'p2x' above. When I ran the script, first it showed the given default value of paramater 'linelength' and second time it showed the value of linelength that was drawn at the execution of script. This seems to be why 'IsNew' doesn't take the value drawn. It always takes the default value because first instance always takes default.

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