Results 1 to 6 of 6

Thread: Annotation Scales and Viewport Scales

  1. #1
    Active Member
    Join Date
    2004-12
    Posts
    80
    Login to Give a bone
    0

    Default Annotation Scales and Viewport Scales

    Anyone know of a way to automatically have the annotation scale match the viewport scale? I have a large amount of drawings and I am trying to save some time so I don't have to go to each one individually and change them.

    Thanks

  2. #2
    Member
    Join Date
    2006-09
    Posts
    14
    Login to Give a bone
    0

    Default Re: Annotation Scales and Viewport Scales

    I also have the same problem and would like to find a solution...Has anyone written a lisp routine to do this?

  3. #3
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Annotation Scales and Viewport Scales

    we have tried and failed, several attempts at it, I dont think it is possible, you can view our research and see if you can come up with anything further. I would still like to have this feature, maybe a wishlist item?

  4. #4
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Annotation Scales and Viewport Scales

    I did it, but it wasn't easy. Unhappily, the code is copyrighted by the firm for which I work.

    I'll see if I can get permission to post the code.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  5. #5
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Annotation Scales and Viewport Scales

    Quote Originally Posted by RobertB View Post
    I did it, but it wasn't easy. Unhappily, the code is copyrighted by the firm for which I work.

    I'll see if I can get permission to post the code.
    perhaps if not, you could post some sort of a pseudo code and we can attempt to figure it out from there?

  6. #6
    Member
    Join Date
    2006-09
    Posts
    14
    Login to Give a bone
    0

    Default Re: Annotation Scales and Viewport Scales

    I started with the code posted in another thread and this is what i have right now. I also have it adding scales that we commonly use to the drawing if they are not there. This routine works sometimes and sometimes it fails (i get ; error: An error has occurred inside the *error* function AutoCAD variable setting rejected: "osmode" nil). Not sure why. Also if you have multiple layout tabs and run it on the first layout then switch to another it then always doesnt set the correct scale for that viewport. it seems as though if on layout 1 cvport 2 was set to 1/8 scale and you switch to layout 2 the cvport 2 is set to 1/4 scale the routine is set the annoscale to 1/8. like it was reading from the first layout. Any ideas?

    Code:
    (defun c:annoscalematch	(/	    CVPORT     CVPRT	  TMODE
    			 VPANNOSCALE	       VPDIST	  VPHEIGHT
    			 VPID	    VPSCALE    VPWIDTH	  VPANNOSC
    			)
    
      (InstallScaleList StdImplScaleList)
      (princ)
    
    
    
    
      (if (wcmatch (getvar "dwgname") "2*")
        (progn
          (setq cvprt (getvar "cvport")
    	    tmode (getvar "tilemode")
          ) ;_ end of setq
          (if (= 1 (setq tmode (getvar "tilemode")))
    	(setvar "tilemode" 0)
          ) ;_ end of if
          (if (/= 1 (setq cvprt (getvar "cvport")))
    	(setvar "cvport" 1)
          ) ;_ end of if
          (setq viewports (ssget "_X" '((0 . "VIEWPORT") (8 . "G-VIEW-PORT")))
    	    count     (sslength viewports)
          ) ;_ end of setq
          (repeat count
    	(setq vport (entget (ssname viewports (setq count (1- count))))
    	      vpid  (cdr (assoc 69 vport))
    	) ;_ end of setq
    
    
    	(if (/= vpid 1)
    	  (progn
    	    (command "._mspace")
    	    (setq vpwidth  (cdr (assoc 40 vport))
    		  vpheight (cdr (assoc 41 vport))
    		  vpdist   (cdr (assoc 45 vport))
    		  vpscale  (/ 1 (/ vpheight vpdist))
    		  vpannosc (rtos vpscale 2 0)
    	    ) ;_ end of setq
    
    	    (cond
    	      ((= vpannosc "24")
    	       (setq vpannoscale "1/2\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "32")
    	       (setq vpannoscale "3/8\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "48")
    	       (setq vpannoscale "1/4\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "64")
    	       (setq vpannoscale "3/16\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "96")
    	       (setq vpannoscale "1/8\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "128")
    	       (setq vpannoscale "3/32\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "192")
    	       (setq vpannoscale "1/16\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "240")
    	       (setq vpannoscale "1\" = 20'-0\"")
    	      )
    
    	      ((= vpannosc "384")
    	       (setq vpannoscale "1/32\" = 1'-0\"")
    	      )
    
    	      ((= vpannosc "10")
    	       (setq vpannoscale "1:10")
    	      )
    
    	      ((= vpannosc "20")
    	       (setq vpannoscale "1:20")
    	      )
    
    	      ((= vpannosc "30")
    	       (setq vpannoscale "1:30")
    	      )
    
    	      ((= vpannosc "40")
    	       (setq vpannoscale "1:40")
    	      )
    
    	      ((= vpannosc "50")
    	       (setq vpannoscale "1:50")
    	      )
    
    	      ((= vpannosc "60")
    	       (setq vpannoscale "1:60")
    	      )
    
    	      ((= vpannosc "80")
    	       (setq vpannoscale "1:80")
    	      )
    
    	      ((= vpannosc "100")
    	       (setq vpannoscale "1:100")
    	      )
    
    	      ((= vpannosc "200")
    	       (setq vpannoscale "1:200")
    	      )
    
    	    ) ;_ end of cond
    
    	    (setvar "cvport" vpid)
    	    (setq cas (getvar "cannoscale"))
    	    (cond
    	      ((/= cas "1'-0\" = 1'-0\"")
    	      )
    	      ((= cas "1'-0\" = 1'-0\"")
    
    
    	       (setvar "cannoscale" vpannoscale)
    	      ) 
    	    ) ;_ end of cond
    	  ) ;_ end of progn
    	) ;_ end of if
          ) ;_ end of repeat
        ) ;_ end of progn
      ) ;_ end of if
    
      (command "._pspace")
    
      (princ)
    
    ) ;_ end of defun
    
    ;; List of standard Imperial scales as per AutoCAD
    (setq StdImplScaleList
           '(("1'-0\" = 1'-0\"" 12.0 . 12.0)
    	 ("6\" = 1'-0\"" 6.0 . 12.0)
    	 ("3\" = 1'-0\"" 3.0 . 12.0)
    	 ("1-1/2\" = 1'-0\"" 1.5 . 12.0)
    	 ("1\" = 1'-0\"" 1.0 . 12.0)
    	 ("3/4\" = 1'-0\"" 0.75 . 12.0)
    	 ("1/2\" = 1'-0\"" 0.5 . 12.0)
    	 ("3/8\" = 1'-0\"" 0.375 . 12.0)
    	 ("1/4\" = 1'-0\"" 0.25 . 12.0)
    	 ("3/16\" = 1'-0\"" 0.1875 . 12.0)
    	 ("1/8\" = 1'-0\"" 0.125 . 12.0)
    	 ("3/32\" = 1'-0\"" 0.09375 . 12.0)
    	 ("1/16\" = 1'-0\"" 0.0625 . 12.0)
    	 ("1\" = 20'-0\"" 1.0 . 240.0)
    	 ("1/32\" = 1'-0\"" 0.03125 . 12.0)
    	 ("1/64\" = 1'-0\"" 0.015625 . 12.0)
    	 ("1:10" 1.0 . 10.0)
    	 ("1:20" 1.0 . 20.0)
    	 ("1:30" 1.0 . 30.0)
    	 ("1:40" 1.0 . 40.0)
    	 ("1:50" 1.0 . 50.0)
    	 ("1:60" 1.0 . 60.0)
    	 ("1:80" 1.0 . 80.0)
    	 ("1:100" 1.0 . 100.0)
    	 ("1:200" 1.0 . 200.0)
    	)
    ) ;_ end of setq
    
    ;; Function to obtain list of scale entity names
    (defun GetScaleListEntities (/ lst item)
      (setq lst nil)
      (foreach item	(dictsearch (namedobjdict) "ACAD_SCALELIST")
        (if	(= 350 (car item))
          (setq lst (cons (cdr item) lst))
        ) ;_ end of if
      ) ;_ end of foreach
      lst
    ) ;_ end of defun
    
    ;; Function to obtain list of scale types in current drawing
    (defun GetScaleList (/ lst lst1 item data)
      (setq	lst  (GetScaleListEntities)
    	lst1 nil
      ) ;_ end of setq
      (foreach item	lst
        (setq data (entget item))
        (setq lst1 (cons (vl-list* (cdr (assoc 300 data))
    			       (cdr (assoc 140 data))
    			       (cdr (assoc 141 data))
    		     ) ;_ end of vl-list*
    		     lst1
    	       ) ;_ end of cons
        ) ;_ end of setq
      ) ;_ end of foreach
    
      ;; Sort the list - most detailed to least
      (setq	lst
    	 (vl-sort lst1
    		  '(lambda (s1 s2)
    		     (> (/ (cadr s1) (cddr s1)) (/ (cadr s2) (cddr s2)))
    		   ) ;_ end of lambda
    	 ) ;_ end of vl-sort
      ) ;_ end of setq
    ) ;_ end of defun
    
    ;; Function to ensure list of scale are installed
    (defun InstallScaleList	(stdlst / lst item cmd)
      (setq lst (GetScaleList))		;Get list of scale entity names
    
      ;; Remove items from stdlst which is already in the drawing
      (setq	stdlst (vl-remove-if
    		 '(lambda (e) (/= nil (assoc (car e) lst)))
    		 stdlst
    	       ) ;_ end of vl-remove-if
      ) ;_ end of setq
    
      (setq cmd (getvar "CMDECHO"))
      (setvar "CMDECHO" 0)
      (command "._undo" "_Begin")
      ;; Start scalelist edit if needed
      (if (> (length stdlst) 0)
        (command ".-scalelistedit")
      ) ;_ end of if
      ;; Step through remainder of stdlst
      (foreach item	stdlst
        (command "_Add"
    	     (car item)
    	     (strcat (rtos (cadr item)) ":" (rtos (cddr item)))
        ) ;_ end of command
      ) ;_ end of foreach
    
      ;; End scalelist edit if needed
      (if (> (length stdlst) 0)
        (command "_Exit")
      ) ;_ end of if
      (command "._undo" "_End")
      (setvar "CMDECHO" cmd)
      (length stdlst)
    ) ;_ end of defun
    
    (princ)
    Last edited by ljacobs; 2008-10-24 at 05:56 PM.

Similar Threads

  1. Replies: 10
    Last Post: 2022-08-25, 10:06 PM
  2. Allow "Custom Views Scales" to be available in the Properties of "Hide in Scales corser than"
    By autocad.wishlist1734 in forum Revit Structure - Wish List
    Replies: 0
    Last Post: 2011-10-07, 01:25 PM
  3. Viewport Toolbar Linked with Annotation Scales
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2009-07-06, 03:23 PM
  4. Purge Annotation Scales That Are Not the Current Active Annotation Scale
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2009-02-01, 06:04 PM
  5. A viewport re-scales
    By Merlin in forum AutoCAD General
    Replies: 2
    Last Post: 2004-10-28, 05:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •