Macro to set a PaperSpace Viewport

Macro to set a PaperSpace Viewport

Anonymous
Not applicable
1,139 Views
1 Reply
Message 1 of 2

Macro to set a PaperSpace Viewport

Anonymous
Not applicable

Good morning,

 

I would like to create a button on a ribbon to insert a viewport at 3/8" = 1'-0" Standard Scale within our title block. I have it placing the viewport to the size needed and on the correct Vport Layer, but cannot seem to figure where to set the Scale or Shade Plot/Visual Style.  Is there a simple way to edit the viewport properties that could be nested within the macro when the Viewport is created?

 

The same question would be setting the view port's Visual Style to Legacy Hidden.

 

Here is the example of my button's macro so far:

^C^C-Layer;s;Viewport;;^C^C-Vports;P;1,3;34,3;34,22;1,22;C;^C^C_MSpace;Zoom;1xp;;^C^CPSpace;^C^C_mview;L;On;All;;

 

Once I can complete this example, I will create the same button for 1/4"=1'-0" and 1/8"=1'-0".

 

Thank you for any help...!

0 Likes
1,140 Views
1 Reply
Reply (1)
Message 2 of 2

ambrosl
Autodesk
Autodesk

Your macro is very close to what you want.  The -VISUALSTYLE command is context sensitive to the viewport that is active, so after you perform the MSPACE command you can then set the visual style you want to use in the viewport before switching back to paper space with the PSPACE command.

 

As for the setting of the scale, you have that in your macro but just need to specify the correct factor as part of the ZOOM command.  Currently the macro is setting the viewport scale to 1:1 (Zoom;1xp;)

 

The following shows how to calculate the needed zoom factor:

 

3/16" = 1'-0"
3/16 = 0.1875
0.1875 / 12 = 0.015625
0.015625xp - 3/16" = 1'-0"

I typically will use the CAL command in AutoCAD and the value returned should be the number of decimal places that are needed for the zoom factor:

 

Command: CAL
>> Expression: (3/16) / 12
0.015625

Here is the revised macro that will create the viewport at a scale of 3/16" = 1'-0" and set the visual style to Hidden:

 

^C^C-Layer;s;Viewport;;^C^C-Vports;P;1,3;34,3;34,22;1,22;C;^C^C_MSpace;Zoom;0.015625xp;;^C^C-visualstyle;C;Hidden;^C^CPSpace;^C^C_mview;L;On;All;;

 

You shouldn't also need all those ^C^C sequences throughout the macro if you are finishing the commands correctly.  You only really need those at the start of the macro to ensure the first command is at a clean command prompt.

 

3/16" = 1'-0"

^C^C-Layer;s;Viewport;;-Vports;P;1,3;34,3;34,22;1,22;C;_MSpace;Zoom;0.015625xp;-visualstyle;C;Hidden;PSpace;_mview;L;On;All;;

 

1/4" = 1'-0"

^C^C-Layer;s;Viewport;;-Vports;P;1,3;34,3;34,22;1,22;C;_MSpace;Zoom;0.0208333333xp;-visualstyle;C;Hidden;PSpace;_mview;L;On;All;;

 

Hope this helps, and good luck with your other macros.



Lee Ambrosius
Senior Principal Content Experience Designer
For additional help, check out the AutoCAD Developer Documentation