Annotation scale in paperspace not 1:1

Annotation scale in paperspace not 1:1

clindner
Advocate Advocate
2,531 Views
13 Replies
Message 1 of 14

Annotation scale in paperspace not 1:1

clindner
Advocate
Advocate

All,

 

As odd as it sounds, paper space actually does have an annotative scale. Typically, this is 1:1. But we (and others) are having instances where this scale has somehow become other than 1:1 (ex: 1'-0"=1'-0", 1/4"=1'-0", etc.). A discussion related to this is in this thread.

 

Autodesk's @john.vellek has been working with me on this and described a promising "hack" in this post. However, in my attempt to automate this fix via AutoLisp, I'm not getting the results I would expect.

 

I'm reaching out to the programming gods to see if they can figure out how to get the code below to perform the way it does when the steps are performed manually, as John described.

 

(defun C:FixLayout (/ pspaceVport pspaceVpObj)
  (setq pspaceVport (ssname (ssget "_x" '((0 . "VIEWPORT") (69 . 1))) 0 ))
  (setq pspaceVpObj (vlax-ename->vla-object pspaceVport))
  (sssetfirst nil (ssadd pspaceVport))
  (princ "\nInitial scales: ")
  (princ "\n - Standard: ")(princ (vla-get-standardscale pspaceVpObj))
  (princ "\n - Standard2: ")(princ (vla-get-standardscale2 pspaceVpObj))
  (princ "\n - Custom: ")(princ (vla-get-customscale pspaceVpObj))
  (vla-put-DisplayLocked pspaceVpObj :vlax-false)
  (vla-put-standardscale pspaceVpObj acVp1_1)
  (vla-put-standardscale2 pspaceVpObj acVp1_1)
  (vla-put-customscale pspaceVpObj 1.0)
  (vla-put-DisplayLocked pspaceVpObj :vlax-true)
  (princ "\nChanged scales: ")
  (princ "\n - Standard: ")(princ (vla-get-standardscale pspaceVpObj))
  (princ "\n - Standard2: ")(princ (vla-get-standardscale2 pspaceVpObj))
  (princ "\n - Custom: ")(princ (vla-get-customscale pspaceVpObj))
  (textscr)
  (princ)
  )

I've attach a sample drawing. In it, layout "A201" has an annotative scale of 1'-0"=1'-0", and layout "A202" has an annotative scale of 1/4"=1'-0". 

 

Thanks!


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

2,532 Views
13 Replies
Replies (13)
Message 2 of 14

Ranjit_Singh
Advisor
Advisor

Try below code

;;Ranjit Singh
(defun c:somefunc  (/ etdata)
 (mapcar '(lambda (x)
           (and (setq etdata (cdr (assoc 360 (entget (cdr (assoc 360 (entget x)))))))
                (setq etdata (entget (cdr (assoc 340 (entget etdata)))))
                (entmod (subst '(300 . "1:1") (assoc 300 etdata) etdata))))
         (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "VIEWPORT"))))))
 (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports))
0 Likes
Message 3 of 14

clindner
Advocate
Advocate

Thanks, @Ranjit_Singh.

 

It returns:

; error: bad argument type: lentityp nil

 

 


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

0 Likes
Message 4 of 14

joselggalan
Advocate
Advocate

Correction to avoid error:

 

(defun c:somefunc  (/ etdata)
 (mapcar
  (function
   (lambda (x)
    (and (setq etdata (cdr (assoc 360 (entget x))))
         (setq etdata (cdr (assoc 360 (entget etdata))))
	 (setq etdata (entget (cdr (assoc 340 (entget etdata)))))
	 (entmod (subst '(300 . "1:1") (assoc 300 etdata) etdata)))
   )
  )
  (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "VIEWPORT")))))
 )
 (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports)
)

regards..

0 Likes
Message 5 of 14

Ranjit_Singh
Advisor
Advisor

Try it now. I need to get in the habit of testing my code before I post.

;;Ranjit Singh
(defun c:somefunc  (/ etdata)
 (mapcar '(lambda (x)
           (and (setq etdata (assoc 360 (entget x)))
                (setq etdata (entget (cdr (assoc 340 (entget (cdr (assoc 360 (entget (cdr etdata)))))))))
                (entmod (subst '(300 . "1:1") (assoc 300 etdata) etdata))))
         (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "VIEWPORT"))))))
 (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acallviewports))
annoscale_setup.gif
0 Likes
Message 6 of 14

clindner
Advocate
Advocate

 

Smiley Happy

 

Thanks again, @Ranjit_Singh.

 

This works on viewport objects, but I'm not talking a traditionally viewport (created via the MVIEW command). The "viewport" I'm referring to is the layout itself (the "paperspace viewport") which, according to John's post, is treated like a viewport (although I always thought layouts were a block!).

 

In the sample drawing I attached in the original post, notice that when you are in layout "A200" and have nothing selected, it shows an annotative scale of 1'-0"=1'-0". with no way to change it.

Screenshot_2017.06.01_15h12m23s_004_.png

 

So, the steps John provided in his post work on the layout viewport itself.

 

(setq pspaceVport (ssname (ssget "_x" '((0 . "VIEWPORT") (69 . 1))) 0 ))
(sssetfirst nil (ssadd pspaceVport))
  • In the Properties palette, set Display Locked to No
  • Change the Annotation Scale to 1:1
  • Set the Display Locked to Yes

Hope that helps clarify.

 


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

0 Likes
Message 7 of 14

Ranjit_Singh
Advisor
Advisor

OK. Try the below code

;;Ranjit Singh
(defun c:somefunc (/ curtab lst1 lst2 etdata) (setvar 'tilemode 0) (setq curtab (getvar 'ctab) lst1 (layoutlist)) (command "._layout" "_n" "") (setq lst2 (layoutlist)) (mapcar '(lambda (x) (setvar 'ctab x) (and (setq etdata (assoc 360 (entget (cdr (assoc 360 (entget (cadar (ssnamex (ssget "_x" (list '(0 . "viewport") (cons 410 (getvar 'ctab)) '(69 . 1))))))))))) (setq etdata (entget (cdr (assoc 340 (entget (cdr etdata)))))) (entmod (subst '(300 . "1:1") (assoc 300 etdata) etdata)))) lst2) (setvar 'ctab curtab) (command "._layout" "_d" (car (vl-remove-if '(lambda (x) (member x lst1)) lst2))) (princ))

annoscale_misc_setup.gif

0 Likes
Message 8 of 14

clindner
Advocate
Advocate

I see what you're doing there! 🙂 It's similar to my current solution (mentioned here), but more elegant!

 

However, it's failing here:

(assoc 360
   (entget (cadar (ssnamex (ssget "_x" (list '(0 . "viewport") (cons 410 (getvar 'ctab)) '(69 . 1)))))))

The (entget) returns a valid entity list, but the (assoc 360 returns nil.

 

Thanks,

 


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

0 Likes
Message 9 of 14

Ranjit_Singh
Advisor
Advisor

Are you using the same drawing that you posted? Or is it a different drawing? Try below code. I added testing for dictionary at one more level. Hopefully, this resolves it.

;;Ranjit Singh
(defun c:somefunc  (/ curtab lst1 lst2 etdata)
 (setvar 'tilemode 0)
 (setq curtab (getvar 'ctab)
       lst1   (layoutlist))
 (command "._layout" "_n" "")
 (setq lst2 (layoutlist))
 (mapcar '(lambda (x)
           (setvar 'ctab x)
           (and (setq etdata (assoc 360
                                    (entget (cadar (ssnamex (ssget "_x" (list '(0 . "viewport") (cons 410 (getvar 'ctab)) '(69 . 1))))))))
                (setq etdata (assoc 360 (entget (cdr etdata))))
                (setq etdata (entget (cdr (assoc 340 (entget (cdr etdata))))))
                (entmod (subst '(300 . "1:1") (assoc 300 etdata) etdata))))
         lst2)
 (setvar 'ctab curtab)
 (command "._layout" "_d" (car (vl-remove-if '(lambda (x) (member x lst1)) lst2)))
 (princ))

 

0 Likes
Message 10 of 14

clindner
Advocate
Advocate

Same drawing.

 

That tweak seemed to take care of it! Nicely done, @Ranjit_Singh!

 

Update: see this post...

 

Thanks!!!


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

0 Likes
Message 11 of 14

clindner
Advocate
Advocate

@Ranjit_Singh,

 

In my excitement, I jumped too soon! 

 

Your code resets the annotation scale of all the actual viewports, not just the "paperspace viewport", to 1:1. I'm not having a problem with viewport objects. They are easy enough to change via the Properties palette or the related tools on the status bar. The whole issue here is that the "paperspace viewport" (i.e. layout) has a non-1:1 annotation scale and there is no way to fix it (as far as I've found) other than the steps I was previously using and the code you provided.

 

My viewports are fine. Its just paperspace that needs fixed. Is there a way to differentiate between a traditional viewport object and the paperspace viewport (i.e. layout)?


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

0 Likes
Message 12 of 14

Ranjit_Singh
Advisor
Advisor

Alright. Back to square 1 I will need to iterate through the current viewports capture the scales and then reset it back after setting the annotation scale.Be back (hopefully with a solution Smiley Wink)

0 Likes
Message 13 of 14

Ranjit_Singh
Advisor
Advisor

Upon further testing, it seems like above code works for all drawings at my end. See example below. This particular line

(ssget "_x" (list '(0 . "viewport") (cons 410 (getvar 'ctab)) '(69 . 1)))

ensures that only paper space viewport is selected. Please try it on some other drawing at your end. See the results on my test drawing.

annoscale_misc_setup2.gif

 

However, I did try to iterate through all viewports after changing annotation scale and it resets viewport to original value but only on layout A200. That indicates something is wrong with the drawing. You already know the dictionary data is missing for one layout (which is shown as missing at different levels for both of us). I would recommend use a clean drawing and copy all elements to this drawing. Then run the earlier code. It should only set the annotation scales of paper space viewport and not the user created viewports. Here is the second code (which for all practical purposes is redundant, since the previous code clearly identifies paperspace viewports), in case you want to try.

;;Ranjit Singh
(defun c:somefunc  (/ curtab lst1 lst2 lst3 etdata)
 (setvar 'tilemode 0)
 (setq curtab (getvar 'ctab)
       lst1   (layoutlist)
       lst3   (mapcar '(lambda (x)
                        (cons x
                              (cdr
                               (assoc 300
                                      (entget (cdr (assoc 340 (entget (cdr (assoc 360 (entget (cdr (assoc 360 (entget x))))))))))))))
                      (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "viewport") (-4 . "<not") (69 . 1) (-4 . "not>")))))))
 (command "._layout" "_n" "")
 (setq lst2 (layoutlist))
 (mapcar '(lambda (x)
           (setvar 'ctab x)
           (and (setq etdata (assoc 360
                                    (entget (cadar (ssnamex (ssget "_x" (list '(0 . "viewport") (cons 410 (getvar 'ctab)) '(69 . 1))))))))
                (setq etdata (assoc 360 (entget (cdr etdata))))
                (setq etdata (entget (cdr (assoc 340 (entget (cdr etdata))))))
                (entmod (subst '(300 . "1:1") (assoc 300 etdata) etdata))))
         lst2)
 (setvar 'ctab curtab)
 (command "._layout" "_d" (car (vl-remove-if '(lambda (x) (member x lst1)) lst2)))
 (mapcar '(lambda (x)
           (setq etdata (entget (cdr (assoc 340 (entget (cdr (assoc 360 (entget (cdr (assoc 360 (entget (car x))))))))))))
           (entmod (subst (cons 300 (cdr x)) (assoc 300 etdata) etdata)))
         lst3)
 (princ))

 

0 Likes
Message 14 of 14

clindner
Advocate
Advocate

Hi, @Ranjit_Singh.

 

Just an update. Using the same sample drawing, I tried the routine again and here's what I found. The viewport scales weren't changed, but some of their names were. In the list below, the "1:1 / 2.08%" was previously labelled 1/4"=1'-0". The second "1:1 / 100%" (the one checked) was previously 1'-0"=1'0". I was able to rename them via SCALELISTEDIT, but just thought you would find it interesting.

Screenshot_2017.06.05_09h37m36s_002_.png

It is possible that the sample drawing I provided is beyond repair. I will do some add'l testing on other more normal drawings (hopefully) and using your recent code to see if there are any other anomalies. 

 

Thanks.

 


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

0 Likes