Jump to content

Script for changing dim style in selected viewports


Recommended Posts

Hi, I was wondering if anyone had a script (or another easy way) to change the dimension style in selected viewports. We have sheets that need to go back and forth between standard and metric dimensions and would love to be able to change them all at once as opposed to going into each viewport and doing it manually. Thanks!

Link to comment

Do you really want to change the Dim Standard or do you just want to be able to switch between showing imperial and metric (or any other set of two dimension)?

 

This first script will change the dimension standard to one set by the Constant ChangeTo. 

Procedure ChangeDimStandard;
{November 1, 2019}
{© 2019 Patrick Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{Changes the dimension standard of a dimension to the string constant}
{defined in ChangeTo. Standard must exist or standard will be Arch}
{Proof of Concept}

Const	ChangeTo='PTS';

Var	H2:Handle;

Procedure Execute(H1:Handle);
	
Begin
	SetObjectVariableString(H1,27,ChangeTo);
	ResetObject(H1);
End;

Begin
	ForEachObject(Execute,((VSEL)));
End;

Run(ChangeDimStandard);

This second script will toggle between displaying the primary and secondary dimensions of a dimension object that is defined as dual dimension. Be careful with this one as you could easily get out of sync and have some dims showing in one unit and other in another.

Both scripts work on all visible selected objects in the drawing, so if you edit the annotations of a viewport, it SHOULD only change the dims in the annotations, but I have not tested for that.

Procedure ToggleDimUnits;
{November 1, 2019}
{© 2019 Patrick Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}

{Toggles between showing Primary and Secondary dimension}
{for Dimension objects defined as Dual Dimension.}
Procedure Execute(H1:Handle);
Begin
	SetObjectVariableBoolean(H1,23,Not GetObjectVariableBoolean(H1,23));
	SetObjectVariableBoolean(H1,6,Not GetObjectVariableBoolean(H1,23));
	ResetObject(H1);
End;

Begin
	ForEachObject(Execute,((VSEL)));
End;

RUN(ToggleDimUnits);

Usual disclaimers. No warranty expressed or implied. Your milage may vary. Test on an inconspicuous spot. Backup everything before using. Do not operate heavy equipment while using. Flame retardant clothing and respirator recommended. Yada, Yada, Yada.

 

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