Jump to content

Macro to switch from Imperial to Metric standard


Recommended Posts

I am looking for a simple toggle or macro to switch back and forth between imperial and metric dimensions. Ideally there would be a setting to allow the user to select which format settings  to use for both states of the toggle. 

 

Does se anyone have something like this?  Having to do this manually is a. It cumbersome as I have drawings where I constantly have to switch back and forth. 

 

Thanks all!  

Link to comment

Scott,

   I use something like this. You should consult the VectorScript Function Reference for PrimaryUnits(), SetUnits() and the Appendix if you want to change any of the settings. The Func Ref is in your application HELP folder, and also online at http://developer.vectorworks.net/index.php/Main_Page. This script works on the document units display, but not on Dimension objects. For that you will need to change the dimension standard applied to individual dimensions; i.e., you'll need another script.

{ Toggle between INCHES and mm. Script BEEPS when Inches are applied. }
{ This script should be customized to meet individual needs. }
{ 21 April 2017 - Ray Mullin. No warranties expressed or implied. }
{ Excessive use may cause finger cramps. Use responsibly. }

if (GetPrefReal(152) = 1) then begin	{ if Units Per Inch = 1 }
	{ style, prec, dimPrec, format, angPrec, showMark, dispFrac }
	{ 7=mm, 3 decimals, 1 Dim decimals, 0=Custom, Angle Fmt 8= 0.0000°, Show unit mark=T, display Feaction=F }
	PrimaryUnits(7, 3, 1, 0, 8, TRUE, FALSE);
	
	{ fraction=0, display=3 decimals, format 0=decimal, UPI, name='mm', square name=' sq mm' }
	SetUnits(0, 3, 0, 25.4, ' mm', ' sq mm');
	
	SetPref(163, TRUE);	{ show unit mark }
	SetPref(164, TRUE);	{ show leading 0 }
	SetPref(165, FALSE);	{ show trailing 0 }
	SetPref(214, TRUE);	{ show leading 0 (dual dimension) }
end
else begin
	{ style, prec, dimPrec, format, angPrec, showMark, dispFrac }
	{ 2=inch, 3 decimals, 2 Dim decimals, 0=Custom, Angle Format 8=0.0000°, Show unit mark=T, display Feaction=F }
	PrimaryUnits(2, 3, 2, 0, 8, TRUE, FALSE);
	
	
	{ fraction=0, display=3 decimals, format 0=decimal, UPI, name='"', square name=' sq in' }
	SetUnits(0, 3, 0, 1, '"', ' sq in');
	
	SetPref(163, TRUE);	{ show unit mark }
	SetPref(164, TRUE);	{ show leading 0 }
	SetPref(165, FALSE);	{ show trailing 0 }
	SetPref(214, TRUE);	{ show leading 0 (dual dimension) }
	
	SysBeep;	{ Beep for INCHES }
end;

Toggle on,

Raymond

  • Like 1
Link to comment
  • 4 years later...

Hello Raymond,

 

Can you advise on how one could modify your script to switch between inches in decimal format to feet and inches in fractional format? I've tested for a few hours, but cannot get anything to work with my limited vector-scripting knowledge. Any hints would be very appreciated.

 

Thank you,

 

Joe

Link to comment

@Joe Pierre,

   This seems like it should be a simple thing to do, but it is not. Additionally, there are probably multiple ways to script a solution. Here's a short script that may suit your needs. If not, you are free to modify it until it does.

 

PROCEDURE DecIn_FracFtIn;
{ Toggle between decimal INCHES and fractional Feet-Inches. }
{ This script should be customized to meet individual needs. }
{ 26 September 2021 - Ray Mullin. No warranties expressed or implied. }
{ Excessive use may cause finger cramps. Use responsibly. }
{ Script BEEPS when decimal Inches are applied. }

	Procedure ResetDims(H :Handle);
	Begin
		ResetObject(H);
	End;		{ ResetDims }

BEGIN
	if (GetPrefInt(170) = 1) then begin	{ if Feet-Inches }
		SetPrefInt(170, 2);		{ Units = Inches }
		SetPref(168, FALSE);		{ False = Decimal }
		SetPref(163, TRUE);		{ Show unit mark }

		ForEachObject(ResetDims, T=Dimension);		{ reset all dimension objects }

		SysBeep;	{ Beep for INCHES }
	end
	else begin				{ if Inches (or another unit) }
		SetPrefInt(170, 1);		{ Units = Feet-Inches }
		SetPref(168, TRUE);		{ True = Fractional }
		SetPref(175, FALSE);		{ Rounding Style True = Exact as fractions; False = Non-exact as decimal }
		SetPrefLongInt(172, 2);		{ Dimension Fractional Precision (0-6); 1=1/2, ..., 6=1/64 }
	end;
END;
Run(DecIn_FracFtIn);

 

 

   Interestingly, dimensions will reformat when the units are changed to Feet-Inches, but they must be manually reset when changing to Inches. Go figure.

 

HTH,

Raymond

 

 

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