Jump to content
Developer Wiki and Function Reference Links ×

Get Snap Box or selection Box Size


PeterT

Recommended Posts

Does anyone know how to get the Snap box or Selection box size in VectorScript?

GetPrefInt(54) returns the Snap Radius, but I am not sure what that even is anymore in VW 2009, as the "radius" was replaced by the "box". And on my system GetPrefInt(54) always returns 5 no matter where the snap or selection box slider controls are.

Anybody know if there are any new preference selectors for this?

Link to comment
Does anyone know how to get the Snap box or Selection box size in VectorScript?

GetPrefInt(54) returns the Snap Radius, but I am not sure what that even is anymore in VW 2009, as the "radius" was replaced by the "box". And on my system GetPrefInt(54) always returns 5 no matter where the snap or selection box slider controls are.

My understanding is that is was always a box.

Try 1010 for the Snap Box size and 1009 for the selection box radius.

Link to comment

Pat,

Thanks for the selectors, they do return the values for the snap box and selection box sliders, but the returned values are sure not what I expected. The biggest box size has a value of 0, and the smallest a value of 5243, with all the values in between being seemingly random positive or negative four and five digit numbers.

I sure would like to know where you got these undocumented preference selectors though, are they listed somewhere?

As far as my script, the values don't specifically matter, as long as I can get them and set them, so I can do what I was hoping to do to improve my script. But as Miguel suggested, I am sure there is a better way to do what I am doing.

I am using GetPickObjectInfo in my script to test a given point for an object and if found, to delete the object. I never realized in version 12.5 that GetPickObjectInfo still uses your snap or selection radius when testing the point. In my mind, a point is a point, not an area. When we upgraded to version 2009, with user controllable selection box size, I noticed my script was deleting unintended objects NEAR the specified point, especially if zoomed out when the script was run. I guess I have the selection box set to a larger size than whatever the default size was in version 12.5.

I think I can improve my script by resetting the selection box size to the smallest size during script execution, then setting it back before exiting the script. But maybe this is not the best way.

My script puts a date in the title block of my sheet or updates the date if one is already there. To update, it just deletes any found date and puts the new date there, but when zoomed out it seems to delete the entire title block if updating.

I tried locking the title block, but VectorScript still seems to delete locked objects. I guess I could test the object type and only delete if text, but that still might delete other nearby text objects in the title block. Also, I would like to avoid naming the date object if possible. Is there a better way of checking a point for an object that does not use the snap radius and find nearby objects?

Anyone have any ideas?

Link to comment

Is you download the Vectorworks SDK (Software development kit), there is a file called Minicad Callbacks.h. In there you can find all sorts of undocumented preferences.

The SDK is what you use if you want to program in C rather then Vectorscript.

Now that I look at it more carefully, both the prefs I gave you earlier are defined as Doubles, If you use GetObjectVariableLongInt you should get something that makes more sense.

As for your delete routine, you may want to consider GetPt() and ForEachObjectAtPoint calls. This may give you more control.

I don't know if it uses the snap radius or not.

Regards,

Pat

Link to comment

Thanks Pat, I will download the SDK an check out the Callbacks file. But as for the preference setting calls, I thought GetObjectVariableLongInt was for object properties. How would I use it to set application preferences? It requires an object handle.

At some point I will test GetPt and ForEachObjectAtPoint for selection box size.

Ramond, In my current script, turning off the snap constraints has no effect. It is not the size of the snapping area that is the issue, it is the size of the selection area, which is now adjustable in the interactive preferences.

At 1:1 scale, and zoomed to 100%, with the selection box preference turned all the way to maximum, clicking on the drawing will select something almost 1/2" away on the diagonal. GetPickObjectInfo seems to pick the point using this setting. I will test GetPt and ForEachObjectAtPoint next.

Thanks for the suggestions.

Link to comment

Pat, I guess I could have figured out you meant GetPrefLongInt, but thanks for the correction. But the returned values are no less confusing than when using GetPrefInt.

But setting the selection box size is moot when using ForEachObjectAtPoint. Rewriting my script to use this call fixes the problem.

ForEachObjectAtPoint would allow me to process only unlocked objects too, but that does not seem necessary as using this call a point is a point, and only objects at the exact point location seem to be found. I tried this at all levels of zoom, and at layers of all different sales, with or without a date object present, and it never deletes the title block.

The funny thing is, in ForEachObjectAtPoint, the last variable is REAL variable called PickRadius. I would have thought this would affect the size of the selection area, but I ran my script with this set to 0, 1, or 1000, and it did not seem to make any difference. There is no documentation on this last variable, so perhaps it is a dummy variable for future use, or obsolete.

Bottom line, my script now works as intended. Thanks for all the input.

Link to comment

One last note, I did find some documentation on the pickRadius in the Annotated Function Reference, but it still does not make a lot of sense to me. It appears my script is working because my title block is grouped.

If I ungroup it though, there does not seem to be any real number I can enter as the pickRadius variable without some part of my title block disappearing at some level of zoom.

I will just have to be sure the title block is grouped before running the script.

Link to comment

There are ?non-functional? variables in quite a few VS calls. An Authority has a host of examples in which they are called ?ThisDoesNothing? or something similar; another Authority a set of variables called IntJunk, RealJunk, StrJunk etc.

It's not as bad as it sounds? In the history of VS/MiniPascal, there are more than enough of examples of ad-hoc calls that do not have the potential of added functionality.

Your concern may be just a case of a not-yet-implemented feature.

With any luck, NNA might finally comprehensively document the relevant alternatives: the various Prefs and ObjectVariables. After all, the progam knows the selection box size and can change it. Us mere mortals are just not allowed to know how it is done.

Not in MiniPascalCallBacks or VWPluginLibraryRoutines? Well, hurry up then, Mr. NNA: we want access to all settings like this.

When do we want it? Now!

Link to comment
My script puts a date in the title block of my sheet or updates the date if one is already there. To update, it just deletes any found date and puts the new date there, but when zoomed out it seems to delete the entire title block if updating.

Anyone have any ideas?

You can update a date in a titleblock by using my free menu command.

It can be found here: http://www.dworks.be/English/Products/Commands/DUpdateTitleBlocks.html

You can set the date and filename and update them. You can even choose to print the page after updating. Just set which coupled text you want to show the date with.

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