Need , lisp routine - take scale from user selected viewport and sync it ...

Need , lisp routine - take scale from user selected viewport and sync it ...

Anonymous
Not applicable
952 Views
3 Replies
Message 1 of 4

Need , lisp routine - take scale from user selected viewport and sync it ...

Anonymous
Not applicable

Hello

Does any one got an lisp that could take the scale from an user selected viewport and put that value into an attribut inside an drawinghead block?

 

For exampel the drawinghead could be named 'Drawinghead' and the attribut could be scale.

 

Thanks in advance...

0 Likes
953 Views
3 Replies
Replies (3)
Message 2 of 4

Jonathan3891
Advisor
Advisor

I wrote this lisp to scale blocks to a selected viewport scale. Maybe it will help you get on track to what your trying to accomplish.

 

;;; Scale Block To Vport Scale W/ Scale Check
;;; By Jonathan Norton
(defun c:sb2vp (/ ss vps ent blok x-scale y-scale entdata ipnt)
  (prompt "\nSelect Viewport: ")
  (setq ss (ssget ":E" '((0 . "VIEWPORT"))))
  (setq vps (vla-get-CustomScale (vlax-ename->vla-object (ssname ss 0))))
  (setq ent (entsel "\nSelect block to scale: "))
  (if (or (null ent)(/= (cdr (assoc 0 (entget (car ent)))) "INSERT"))
    (while (or (null ent)(/= (cdr (assoc 0 (entget (car ent)))) "INSERT"))
      (princ "\nSelect block to scale: ")
      (setq ent (entsel "\nSelect block to scale: "))
      );;while
    );;if
  (setq blok (vlax-ename->vla-object (car ent))
      x-scale (vla-get-xscalefactor blok)
      y-scale (vla-get-yscalefactor blok)
      )
  (setq entdata (entget (car ent)))
  (setq ipnt (cdr (assoc 10 entdata)));;get insertion point
  (if (equal vps x-scale 0.0000007)
    (alert "Block Scaled Correctly!")
    (command "_.scale" ent "" ipnt vps)
    );;if
  (princ)
  )

Jonathan Norton
Blog | Linkedin
0 Likes
Message 3 of 4

3wood
Advisor
Advisor

You can use a field in the block attribute to show such scale.

This field can be defined in the attribute definition (Command ATTDEF, Image 2).

In the field, insert a formula which contains another field. The second field is the "Customer Scale" property of the viewport object. (Image 1)

 

You can then WBLOCK the viewport together with the title block as a new dwg file (Let's call it "A").

Then insert "A" in a layout of a new drawing, explode "A", then select the viewport and turn  it on. (Image 3)

 

Image 1 - Define the field

Capture.PNG

 

Image 2 - Insert field in the block attribute

 Capture1.PNG

 

Image 3 - Turn on viewport after exploding "A"

Capture 3.PNG

0 Likes
Message 4 of 4

pbejse
Mentor
Mentor

 


@Anonymous wrote:

Hello

Does any one got an lisp that could take the scale from an user selected viewport and put that value into an attribut inside an drawinghead block?

 

For exampel the drawinghead could be named 'Drawinghead' and the attribut could be scale.

 

Thanks in advance...


Use Sheet Sets : Mastering AutoCAD Sheet Sets 

Not just syncing view title name and scale but also reference call outs and more

 

Sheet Set- View labels w/ automating view label data 

 

HTH

 

 

 

 

 

0 Likes