See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 29

Thread: Using vlisp to access scales list

  1. #1
    Member
    Join Date
    2009-08
    Posts
    20
    Login to Give a bone
    0

    Default Using vlisp to access scales list

    Hello all,

    I am trying to write a vlisp program that clears the annotation scale list in a drawing and creates scales that only our company needs. However, I cannot find where AutoCAD stores the scales list. It it a dictionary or collection somewhere in the modelspace or paperspace object? Any help would be appreciated on how to access the scales list object using vlisp WITHOUT using the "command" function.

    Thanks guys,

    Brett

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    Quote Originally Posted by baustin View Post
    However, I cannot find where AutoCAD stores the scales list. It it a dictionary or collection somewhere...
    Current Drawing/Named Objects Dictionary/ACAD_SCALELIST

    There is an example of what I think you are trying to do here:
    http://www.cadtutor.net/forum/showthread.php?t=39184
    R.K. McSwain | CAD Panacea |

  3. #3
    Member
    Join Date
    2009-08
    Posts
    20
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    Quote Originally Posted by rkmcswain View Post
    Current Drawing/Named Objects Dictionary/ACAD_SCALELIST

    There is an example of what I think you are trying to do here:
    http://www.cadtutor.net/forum/showthread.php?t=39184
    Thanks a ton. That is a big help. Now, to take this further, I would like to add scales that don't already exist. Could you give me a line of code that would add a scale to the "csobj" object with name "1mm = 50mm" and ratio 1:50. I can't seem to get a hold of the properties of one of these scales (the all seem to have names like <Entity name: 7ee66588>. Any additional help would be great! Thanks!

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    Quote Originally Posted by baustin View Post
    I can't seem to get a hold of the properties of one of these scales (the all seem to have names like <Entity name: 7ee66588>. Any additional help would be great! Thanks!
    Check out ScaleListDel.lsp by Steve Johnson here:
    http://discussion.autodesk.com/forum...sageID=5685088

    There may be a newer version than 0.7 out there, I'm not sure. This looks like it does what you need. Be sure to read the comments in the file.
    R.K. McSwain | CAD Panacea |

  5. #5
    Member
    Join Date
    2009-08
    Posts
    20
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    For anyone who cares, I finally came up with two functions. The first function purges all scales except for the scales supplied in the list. The second function adds a scale given the name and PS:MS ratio. Works in AutoCAD 2009.
    Attached Files Attached Files

  6. #6
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    I added a little twist to this routine. I used the LSP above and created a routine that ALWAYS deletes all annotation scales and ALWAYS sets the default to 1:1. This will work even if the 1:1 annotation scale is missing.

    We are having too many problems with THOUSANDS of annotation scales. We are using the cleanup utility over and over. This way, when someone opens a drawing it will automatically set the scale to 1:1 and delete the rest.

    Code:
    (defun PurgeAnnoScales (/ slist scaleDict scaleDictName csobj num index scaleObject item entnm ent aScale
    		      tempNameObj tempFirst RatioObj tempLastRatioObj tempDictList tempDictListEnt
    		      newScaleDict)
    		(setq slist '("1:1"))
    		(setq scaleDict (dictsearch (namedobjdict) "ACAD_SCALELIST"))
    		(setq scaleDictName (cdar scaleDict))
    		(setq csobj (vlax-ename->vla-object scaleDictName))
    		
    		(setq num (vla-get-count csobj))
    		(setq index 0)
    		(repeat num
    			(setq scaleObject (vlax-invoke-method csobj 'item index))
    			(setq entnm (vlax-vla-object->ename scaleObject))
    			(setq ent (entget entnm))
    			(if (not (member (setq aScale (cdr (assoc 300 ent))) slist))
    				(progn (entdel entnm))
    				(progn (setq index (+ index 1)))
    			)
    		)
                    (if (= 0 (vla-get-count csobj))
    		  (progn
    		  ;CONSTRUCT THE FEATURE DATA PAIR
    		  (setq tempNameObj (cons 300 "1:1"))
    		  (setq tempFirstRatioObj (cons 140 1.0))
    		  (setq tempLastRatioObj (cons 141 1.0))
    		  (setq tempDictList (append (list '(0 . "SCALE") '(100 . "AcDbScale")) (list tempNameObj) (list tempFirstRatioObj) (list templastRatioObj)))
    		  (setq tempDictListEnt (entmakex tempDictList))
    		  (setq newScaleDict (dictadd scaleDictName (strcat (rtos 1.0 2 6) "_" (rtos 1.0 2 6)) tempDictListEnt))
    		  (setvar "cannoscale" "1:1")
    		  );end progn
    		  (setvar "cannoscale" "1:1")
    		  );end if
      (princ));end

  7. #7
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    1

    Default Re: Using vlisp to access scales list

    Please be very careful while doing that. Deleting annotative scales programatically does not check if those scales have already been assigned to entities (like the command SCALELISTEDIT does). So it's possible to erase a scale which is already assigned ... and this could cause ACad to freeze when the user later selects one of those entities.

    Even if you later add the scale back, the link between the entity & the scale is lost, since it's linked using an EName instead of the scale's text name. I've done a similar thing before, and due to this I decided against deleting scales programatically, rather use the command line version of -SCALELISTEDIT to delete scales by passing "*" as the name to delete ... this will delete all non-assigned scales. You can still run this from ACADDOC.LSP to make it happen on DWG open.

    Of course if you're sure that you will never use any annotative objects ... ever ... this "shouldn't" be a problem. But that may even include other DWG's you're importing from other consultants ... now can you be sure that all drawings from all parties (outsiders included) will not use annotative objects?

  8. #8
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    irneb,

    Yes, I did think of all of that. And we NEVER use annotative scaling.

    Oh, wait.... ALL OF US USE ANNOTATIVE SCALING!!!

    These wonderful little annotative scales show up in the plot dialog. It looks like I'm going to revise my LSP to include our standard scales.

    Thanks for nothing, adesk.
    Attached Images Attached Images

  9. #9
    AUGI Addict bowlingbrad's Avatar
    Join Date
    2003-11
    Location
    Chicago
    Posts
    1,233
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    Does anyone know how to order the scales via lisp? I have the routine setting them in order:

    "6\" = 1'-0\""
    "3\" = 1'-0\""
    "1-1/2\" = 1'-0\""
    "1\" = 1'-0\""
    "3/4\" = 1'-0\""
    "1/2\" = 1'-0\""
    "3/8\" = 1'-0\""
    "1/4\" = 1'-0\""
    "3/16\" = 1'-0\""
    "1/8\" = 1'-0\""
    "3/32\" = 1'-0\""
    "1/16\" = 1'-0\""
    "1/32\" = 1'-0\""
    "1/64\" = 1'-0\""
    "1\" = 10'"
    "1\" = 20'"
    "1\" = 30'"
    "1\" = 40'"
    "1\" = 50'"
    "1\" = 60'"
    "1\" = 100'"
    "1\" = 200'"
    "1\" = 500'"

    But they end up looking like this in the annotation scales list:

    "1\" = 1'-0\""
    "1\" = 10'"
    "1\" = 100'"
    "3/32\" = 1'-0\""
    "3/4\" = 1'-0\""
    "1/16\" = 1'-0\""
    "6\" = 1'-0\""
    "1/2\" = 1'-0\""
    "1\" = 20'"
    "1\" = 200'"
    "3/8\" = 1'-0\""
    "1\" = 30'"
    "1/32\" = 1'-0\""
    "3\" = 1'-0\""
    "1/4\" = 1'-0\""
    "1\" = 40'"
    "1\" = 50'"
    "1\" = 500'"
    "3/16\" = 1'-0\""
    "1\" = 60'"
    "1/64\" = 1'-0\""
    "1-1/2\" = 1'-0\""
    "1/8\" = 1'-0\""
    "1:1"

  10. #10
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Using vlisp to access scales list

    It's a bit involved to order them correctly. They're saved in a dictionary list using a numbering scheme. So you'll have to modify the dictionary to sort them.

    To see how this actually works, use my DICTEDIT command from this post: http://forums.augi.com/showpost.php?...80&postcount=7

    It's meant for data links, but it indicates all dictionaries inside the drawing. Allowing you to drill down into the various sub-dictionaries / items.

Page 1 of 3 123 LastLast

Similar Threads

  1. scale list missing fractional scales
    By JRBOURNE in forum CAD Management - General
    Replies: 5
    Last Post: 2011-10-18, 05:10 PM
  2. Permanently Add Scales to Scale List?
    By danielmiller19929945 in forum AutoCAD Customization
    Replies: 2
    Last Post: 2011-05-23, 12:43 PM
  3. Replies: 3
    Last Post: 2009-06-03, 06:35 AM
  4. Engineering Scales Added to Scale List
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 6
    Last Post: 2009-02-10, 07:43 PM
  5. Editable scales list
    By roelie in forum AutoCAD Wish List
    Replies: 10
    Last Post: 2005-01-12, 12:52 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
  •