Jump to content
Sign in to follow this  
PeterT

GetPickObjectInfo Question

Recommended Posts

When using GetPickObjectInfo, what happens if you have two objects at the same specified point?

For which object will the function return a handle? And if you want the handle for the other object instead, how do you get the other object's handle?

In my procedure I want to delete one object at a specified point but not delete another at the same point.

If I use a WHILE loop, it finds object 1. Then, if I delete object 1, it finds object 2.

But what if I only want to delete object 2 and not object 1.

I can specify to only delete objects of type 2, but if it finds object 1 first, it never exits the WHILE loop. It keeps finding itself and doing nothing.

If object 1 does not meet the type 2 criteria, how do I tell it to return a handle to the other object at the same location?

Object 1 is locked and object 2 is not, but VectorScript still deletes object 1 if it finds it first.

Sending one object to the front or back does not seem to help either, so what do I do? Any help appreciated.

Share this post


Link to post

Peter,

When you find an object at a point, move it (rather than delete it) and look again. Repeat until you find no object. Then put them all back. Save all handles and process the one(s) you want.

Raymond

Share this post


Link to post

Thanks Ramond,

That makes sense, I just didn't think of that. I was just hoping there would be a way of determining which object was picked if two were stacked. It would be easy if I knew for sure which of the two would be picked first.

The move technique works fine in my script, but the interesting thing is that using HMove, I get a warning if the object is locked.

HMove will not move a locked object, it must be unlocked first, but DelObject will delete an object even if it is locked. This does not seeem very consistent.

So I guess its trial and error whether Handle Procedures will work on locked objects or not. Is this right?

Share this post


Link to post

quote:

So I guess its trial and error whether Handle Procedures will work on locked objects or not. Is this right?

I would say so. I always test code against the locked condition, and also against a shifted origin. When I forget, strange things happen. You also never know when it may change from version to version, so you need to check again after each upgrade.

I use something like the following procedure in my Reshaper PlugIn before modifying any object, and now I don't wory about the locked state.

code:

procedure hMoveIt(H :Handle; X, Y :Real);

{ Move object in 2D, even if it is locked. }

Var

wasLocked :Boolean;

Begin

wasLocked := GetObjectVariableBoolean(H, 700); { save locked state }

SetObjectVariableBoolean(H, 700, False); { force unlocked }

hMove(H, X, Y);

SetObjectVariableBoolean(H, 700, wasLocked); { reset locked state }

End; { hMoveIt }
[/code]

Raymond

PS - Just curious. Were you able to delete your WGR the way you wanted? (See your post from last week.)

[ 12-08-2005, 11:41 AM: Message edited by: MullinRJ ]

Share this post


Link to post

Hi Ramond,

quote:

Were you able to delete your WGR the way you wanted? (See your post from last week.)

I didn't see your contribution to my WGR post until today. I will look into the active layer thing and see if that was my problem. If what you say is true, I can simplify my script a lot.

But getting back to the GetPickObjectInfo script, I am now further confused about a couple of things.

Unlocking the titleblock, moving it out of the way, deleting the text, then moving the titleblock back and relocking it works, but it sure seems like more code than I should need.

The object I am trying to delete is a date in a box of my title block. I want to delete the date to update it without deleting the box it is contained by.

The box has no fill, and is grouped with the rest of the title block elements, and the whole title block group is locked. The date is separate text object centered in the box and unlocked.

The first problem I had was when I ran my routine it would delete my entire title block and not the date.

Although GetPickObjectInfo specified the center point of my box which has no fill, it would still pick the box object group instead of the text object.

Upon further investigation, when I zoom in closer than about 80% when I run the script, it does not delete the title block at all, but when I zoom back out to above 80% and run the script, the block is deleted.

My thought was that GetPickObjectInfo must be using the current SnapRadius setting in picking the object. This seems crazy to me, as a point is a point, and why would a specifically input point be affected by the snap radius?

So to test, I changed my snap radius to 0, and then to 20 ran my routine at both settings, but it made no difference. At either setting. Below 80% zoom the title block remains, zoom out and it is deleted.

What is going on here? Does VectorScript use an internal snap radius for picking objects, maybe the default 5?

If not, why would a unfilled box or group be picked by a point specified in the middle of the unfilled area? I sure cannot pick it in the drawing environment by clicking the mouse at the center of the box.

Share this post


Link to post

Peter,

I haven't tested this, but perhaps if an object is completely off screen it becomes less selectable.

Without trying to dig into that aspect yet, have you considered giving the date in your title block a 'Name'? You could use something like H:=GetObject('TBDate') to return a handle to that text object, then use SetText(H, Date(1,0)) to change the date without deleting it.

If you have multiple title blocks in your drawing, you could give the dates sequential names, as 'TBDate-01', and search and update them all from a loop.

This method may or may not be relevant, as determined by the rest of your program. If not, we can work through the GetPickObjectInfo options.

HTH,

Raymond

Share this post


Link to post

Thanks Ramond,

I modified my script using SetName, GetObject, and SetText and it is working great. I have never used object names to identify objects in VectorWorks, but this might be a good time to start.

In my current routine, the first time I run it, there is no date yet, so it just places the date. Any subsequent times, it would find the existing date and update it.

This will work great from now on, the only minor flaws I can think of are on previously dated sheets, or if someone manually dates a sheet rather than using the script, the date object will not have a name and when updated using the script, a new date will be placed on top of the old date.

I guess that is why I was trying to use GetPickObject as it would find any date that was in the box.

I still would like to understand why the level of zoom would affect picking an object, or why an unfilled rectangle would be picked at all if not picked on its edge, but in the middle.

Thanks for your help,

Peter

Share this post


Link to post

Peter,

You are welcome. I don't know why an unfilled Rect could be chosen as you describe it, nor how zoom affects selection either. Perhaps some other day.

Returning to your script, you can still use your GetPickObjectInfo routine to search for text blocks if you don't find a named date object. If you find one, sans name, you can discard it and install a new one, named, of course. It might make your code more bullet proof.

Raymond

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...