Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Set SNAP setting in all paperspace tabs

johnw
Collaborator

Set SNAP setting in all paperspace tabs

johnw
Collaborator
Collaborator

Is there an easy way to change all my snap settings in every PAPERSPACE at one time to be a half inch?

 

Thanks in advance for your help!

 

Happy Holidays!

 

John

0 Likes
Reply
Accepted solutions (3)
1,130 Views
11 Replies
Replies (11)

paullimapa
Mentor
Mentor
Accepted solution

You can create a lisp routine to step through each layout tab to set the Snap value:

(defun c:SetSnapL (/ curtab count layouts layoutname snapspace)

(setq count 0)

(setq layouts (layoutlist)) ; retrieve all layout names

(if layouts ; if there are layouts

 (progn

  (setq curtab (getvar"ctab")) ; retrieve current tab location

  (setq snapspace (getreal"\nEnter New Snap Spacing:")) ; request user to enter new snap spacing

 (repeat (length layouts) ; start a loop base on # of layouts

  (setq layoutname (nth count layouts)) ; get one of the layout names

  (command"ctab" layoutname) ; change to that layout

  (command"_.Snap" snapspace)

  (setq count (1+ count))

 ) ; repeat

 (setvar"ctab"curtab) ; set current layout back to original location

 ) ; progn

) ; if

) ; defun

 

Lisp file attached.

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes

Ranjit_Singh2
Advisor
Advisor
Accepted solution

Maybe like this

(defun c:somefunc ( / )
(foreach i (layoutlist) (command "._pspace" "._snap" 0.5)))

johnw
Collaborator
Collaborator
Thanks Ranjit! Happy Holidays!
0 Likes

johnw
Collaborator
Collaborator
Thanks Paul. Does your code do anything different than Ranjits?
0 Likes

paullimapa
Mentor
Mentor

My code provides more flexibility in the following areas:

- works even if you are currently in Model tab

- requests for a user specified Snap spacing value

- returns to current tab 

 

Give it a try yourself and let me know what you think.

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Ranjit_Singh2
Advisor
Advisor

@Anonymous wrote:
Thanks Paul. Does your code do anything different than Ranjits?

I know the question is for @paullimapa. But I just noted that my code has a very silly mistake. It fails to set the current tabs. I have fixed it below

(defun c:somefunc ( / )
(foreach i (layoutlist) (setvar 'ctab i) (command "._pspace" "._snap" 0.5)))
0 Likes

johnw
Collaborator
Collaborator

Hi Paul, first off thanks for writing this code. I've tested both yours and Ranjit's versions and yours is extremely more faster than his (for whatever reason). I initially used his code but it took a very long time to cycle through all 40 viewports. I then tested yours and it took a fraction of the time.

 

Odd because you would think both would do the same thing.

 

Thanks to both of you for all your help!

 

Happy Holidays!

 

John

0 Likes

paullimapa
Mentor
Mentor

I think Ranjit's version could be slower because he also checks to make sure after switching to each of the layout tab to make sure you are in Paperspace and not in a Model space Vport before changing the Snap setting.  I've adding this into the code.  You may want to test if that slows it down.

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Ranjit_Singh2
Advisor
Advisor

@Anonymous wrote:

.......I initially used his code but it took a very long time to cycle through all 40 viewports. I then tested yours and it took a fraction of the time.

 .......

John


That's only because @paullimapa made an assumption that all your 40 viewports are set to paperspace being active. If any or all of those viewports had a modelspace active (through the viewport) then the snap setting was not applied to paperspace.

0 Likes

Ranjit_Singh2
Advisor
Advisor
Accepted solution

My assumption is that you are always in Mspace through viewport which is not helping either. Maybe checking if in mspace and then calling pspace will be better.

 

(defun c:somefunc( / )
(foreach i (layoutlist)
(setvar 'ctab i)
(and (/= 1 (getvar 'cvport))
(command "._pspace"))
(command "._snap" 0.5)))

paullimapa
Mentor
Mentor
0 Likes