Jump to content
WhoCanDo

Push & Pop Constrains

Recommended Posts

Hi,

 

SetConstrain will set the constrains, but how do I get the constrains before I change them so I can return them to the user's preferences afterward?

 

Basically, I want to turn Q on and off but not change any other constrain.

 

Regards

Share this post


Link to post

Hello @WhoCanDo ,

   The constraint settings can be accessed by preference numbers. Here's a routine I wrote a couple of years ago that will do what you're looking for.

	function GetSnaps :String;
	{ Return a string with the current SNAP settings. }
	Var
		S :String;
	Begin
		S := '';
		if GetPref(37) then S := 'A';			{ Snap to Grid }
		if GetPref(1312) then S := concat(S, 'S');	{ Snap to Angle }
		if GetPref(1314) then S := concat(S, 'D');	{ Smart Points }
		if GetPref(1316) then S := concat(S, 'F');	{ Smart Edge }
	
		if GetPref(38) then S := concat(S, 'Q');	{ Snap to Object }
		if GetPref(1313) then S := concat(S, 'W');	{ Snap to Intersection }
		if GetPref(1315) then S := concat(S, 'E');	{ Snap to Distance }
		if GetPref(1317) then S := concat(S, 'R');	{ Snap to Tangent }
		GetSnaps := S;
	End;		{ GetSnaps }

 Enjoy,

Raymond

Share this post


Link to post

Nice one Raymond,

 

If it can be done the long way, I wonder why VW doesn't have a GetConstrain function?

 

Thanks again 😉

Share this post


Link to post

There is probably not a GetConstraint because you can use PushAttrs to save all of the attributes and constraints and then restore them using PopAttrs when you are done.

 

Use those at the begining and end of your script and you can change things as you like while the script runs and give the user back their environment just as you got it.

Share this post


Link to post

I started with that theory Pat but it didn't work, resulting in my question and fabulous answer from Raymond.

 

Regards 

Share this post


Link to post

I did not test, just went be the statement in the VS Function Reference that Push and Pop are supposed to reset constraints.

 

If they don't please enter a bug so it can get it fixed.

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.


 

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