Changing annotative scale and scale of viewports

Changing annotative scale and scale of viewports

Anonymous
Not applicable
1,779 Views
10 Replies
Message 1 of 11

Changing annotative scale and scale of viewports

Anonymous
Not applicable

Hello,

 

How could i set the annoative scale and scale of all viewports from a drawing, using a code?

 

Thanks in advance.

0 Likes
1,780 Views
10 Replies
Replies (10)
Message 2 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

 

How could i set the annoative scale and scale of all viewports from a drawing, using a code?

 


 

 

Look into vla-put-customscale

 

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

Hello,

 

and annotative scale can be set with vlax-put-property?

0 Likes
Message 4 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

 

and annotative scale can be set with vlax-put-property?


 

Yes. You are referring to a viewport right?

Show us what you have, and we'll point you in the right direction

 

 

 

 

0 Likes
Message 5 of 11

Anonymous
Not applicable

Yes, i am talking about vports

This is my idea:

 - you specify inside the code the scale and annotative scale

 - the lisp will apply these scales to all layouts and then it will block them

 

But I dont know how to code for the annotative scale

   (defun c:1 (/ fen n sel tot) 

  (vl-load-com)

  (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
  (if (setq sel (ssget "x" (list (cons 0 "VIEWPORT"))))
    (progn
      (setq n 0 tot 0)
      (while (ssname sel n)
        (if (and (= (logand (cdr (assoc 90 (entget (ssname sel n)))) 16384) 0) (/= (cdr (assoc 69 (entget (ssname sel n)))) 1))
          (progn
            (setq fen (vlax-ename->vla-object (ssname sel n)))
	    (vlax-put-property fen 'CustomScale 0.25) ;; aqui debes poner el factor de escala normal (resultado de 1000/escala deseada)
            (vlax-put-property fen "displaylocked" :vlax-true)
            (setq tot (1+ tot))
          )
        )
        (setq n (1+ n))
      )
      (princ (strcat "\n"  (itoa tot) " VPorts locked )"))
    )
    (princ "\nNO VPorts ! ")
  )
  (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  (princ)
)

 

0 Likes
Message 6 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

Yes, i am talking about vports

This is my idea:

 - you specify inside the code the scale and annotative scale

 - the lisp will apply these scales to all layouts and then it will block them

 


 

Are you wanting to select from a list of existing annotative scales?  Then apply the selected scale to all the viewports.

 

 

 

 

0 Likes
Message 7 of 11

Anonymous
Not applicable

Hello,

 

Yes there is a default scale list which you can add more scales (scalelistedit)

 

and you say to apply the selected scale to all viewports, but, how? 

0 Likes
Message 8 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

 

but, how? 


 

First, collect all existing Annoscale

 

(setq AnnoscaleList
	(mapcar (function (lambda (scle / ent d)
			    (Setq ent (entget (cdr scle)))
			    (setq d (mapcar '(lambda (as)
						(cdr (assoc as ent))) '(300 140 141)))
			       (list (Car d) (/ (cadr d)(caddr d)))))			       
		(vl-remove-if-not '(lambda (as)
				     (= 350 (car as)))
				     (dictsearch (namedobjdict) "ACAD_SCALELIST"))
		)
	)

 

 

Fill up a list box with that value from the above snippet

 

(mapcar 'car AnnoscaleList)

 

After selection, apply the second value based on the selected item

 

(Cadr (assoc  [selected item]  AnnoscaleList)

then assign the value to selected viewports

 

 

(vlax-put-property fen 'CustomScale [ from the snippet above ] )

 

 

HTH

 

Holler if you need help.

 

 

 

 

 

 

 

0 Likes
Message 9 of 11

Anonymous
Not applicable

Hello 

 

 

0 Likes
Message 10 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

Hello 

 

 


 

You mean you want to be prompted for the scale?

 

  (if (and
	(setq sel (ssget "x" (list (cons 0 "VIEWPORT"))))
	(setq scale (getint "\nEnter viewport scale to apply: <1/-> "))
	)

and

(vlax-put-property fen 'CustomScale (/ 1.0 scale))

HTH

 

 

 

 

 

0 Likes
Message 11 of 11

Anonymous
Not applicable

Hello 

 

(defun c:camesca (/ fen n sel tot) 

  (vl-load-com)

  (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
  (if (setq sel (ssget "x" (list (cons 0 "VIEWPORT"))))
    (progn
      (setq n 0 tot 0)
      (while (ssname sel n)
        (if (and (= (logand (cdr (assoc 90 (entget (ssname sel n)))) 16384) 0) (/= (cdr (assoc 69 (entget (ssname sel n)))) 1))
          (progn
            (setq fen (vlax-ename->vla-object (ssname sel n)))
		(setq layoutOld (getvar "CTAB"))
			(foreach layoutCrt (layoutlist)
				(setvar "CTAB" layoutCrt)
				(command "_mspace")
				(command "_cannoscale"
				"1:4") ;; aqui se pone la escala anotativa. Debe existir ya en la lista de editatlistaescala
				(command "_pspace")
			)
		(setvar "CTAB" layoutOld)
	    (vlax-put-property fen 'CustomScale 0.25) ;; aqui debes poner el factor de escala normal (resultado de 1000/escala deseada)
            (vlax-put-property fen "displaylocked" :vlax-true)
            (setq tot (1+ tot))
          )
        )
        (setq n (1+ n))
      )
      (princ (strcat "\n"  (itoa tot) " VPorts locked )"))
    )
    (princ "\nNO VPorts ! ")
  )
  (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  (princ)
)
(princ)
0 Likes