Jump to content

Recommended Posts

Posted

I am creating this lisp to insert scales but I get an error "Invalid Option Keyword" and it kicks me out of the routine. I was wondering if there is a way to fix this. From what I can understand is happening is that, say it gets to 1/4" = 1'-0" and that scale is already in use in a drawing it will kick back that error and wont continue on. Another part of the problem is that it wont delete scales that are in use so when it goes to create these scales some of them already exist, so deleting them all doesn't work. Is there a way to make it continue on with out kicking out of the routine? Any help would be appreciated.

 

I initially tried to stay in the command but I had the idea that if I exit out of the command each time if scale exists it would continue onto the next. Here is what I have so far:

 

(defun c:IS()
(setvar "cmdecho" 0)
(command "_.-scalelistedit" "d" "*" "e")
(command "_.-scalelistedit" "a" "1:1" "1:1" "e")
(command "_.-scalelistedit" "a" "1:2" "1:2" "e")
(command "_.-scalelistedit" "a" "1:4" "1:4" "e")
(command "_.-scalelistedit" "a" "1:8" "1:8" "e")
(command "_.-scalelistedit" "a" "1\" = 1'-0\"" "1:12" "e")
(command "_.-scalelistedit" "a" "1/2\" = 1'-0\"" "0.5:12" "e")
(command "_.-scalelistedit" "a" "1/4\" = 1'-0\"" "0.25:12" "e")
(command "_.-scalelistedit" "a" "3/16\" = 1'-0\"" "0.01875:12" "e")
(command "_.-scalelistedit" "a" "1/8\" = 1'-0\"" "0.125:12" "e")
(command "_.-scalelistedit" "a" "3/32\" = 1'-0\"" "0.09375:12" "e")
(command "_.-scalelistedit" "a" "1/16\" = 1'-0\"" "0.0625:12" "e")
(command "_.-scalelistedit" "a" "1/32\" = 1'-0\"" "0.03125:12" "e")
(command "_.-scalelistedit" "a" "1/64\" = 1'-0\"" "0.015625:12" "e")
(command "_.-scalelistedit" "a" "1\" = 10'-0\"" "1:120" "e")
(command "_.-scalelistedit" "a" "1\" = 20'-0\"" "1:240" "e")
(command "_.-scalelistedit" "a" "1\" = 25'-0\"" "1:300" "e")                             
(command "_.-scalelistedit" "a" "1\" = 30'-0\"" "1:360" "e")
(command "_.-scalelistedit" "a" "1\" = 40'-0\"" "1:480" "e")
(command "_.-scalelistedit" "a" "1\" = 50'-0\"" "1:600" "e")
(setvar "cmdecho" 1)
(princ "\nA quote: \"")
)
(prompt "Insert Scales Loaded.")
(princ)

 

This is without exiting the command:

(defun c:IS()
(setvar "cmdecho" 0)
(command "_.-scalelistedit" "d" "*" "e")
(command "_.-scalelistedit" "a" "1:1" "1:1"
                            "a" "1:2" "1:2"
                            "a" "1:4" "1:4"
                            "a" "1:8" "1:8"
                            "a" "1\" = 1'-0\"" "1:12"
                            "a" "1/2\" = 1'-0\"" "0.5:12"
                            "a" "1/4\" = 1'-0\"" "0.25:12"
                            "a" "3/16\" = 1'-0\"" "0.01875:12"
                            "a" "1/8\" = 1'-0\"" "0.125:12"
                            "a" "3/32\" = 1'-0\"" "0.09375:12"
                            "a" "1/16\" = 1'-0\"" "0.0625:12"
                            "a" "1/32\" = 1'-0\"" "0.03125:12"
                            "a" "1/64\" = 1'-0\"" "0.015625:12"
                            "a" "1\" = 10'-0\"" "1:120"
                            "a" "1\" = 20'-0\"" "1:240"
                            "a" "1\" = 25'-0\"" "1:300"                             
                            "a" "1\" = 30'-0\"" "1:360"
                            "a" "1\" = 40'-0\"" "1:480"
                            "a" "1\" = 50'-0\"" "1:600" "e")
(setvar "cmdecho" 1)
(princ "\nA quote: \"")
)
(prompt "Insert Scales Loaded.")
(princ)

Posted

You must eliminate 1:1 from your scale list since it always exists even after erasing all scales.

Posted (edited)

(setvar 'Expert 5)

 

(defun c:IS_  ( / Scalelist i n)
     (setvar "cmdecho" 0)
     (setvar "expert" 5)
     (setq ScaleList
                (list
                      '("1:2" "1:2")
                      '("1:4" "1:4")
                      '("1:8" "1:8")
                      '("1\" = 1'-0\"" "1:12")
                      '("1/2\" = 1'-0\"" "0.5:12")
                      '("1/4\" = 1'-0\"" "0.25:12")
                      '("3/16\" = 1'-0\"" "0.01875:12")
                      '("1/8\" = 1'-0\"" "0.125:12")
                      '("3/32\" = 1'-0\"" "0.09375:12")
                      '("1/16\" = 1'-0\"" "0.0625:12")
                      '("1/32\" = 1'-0\"" "0.03125:12")
                      '("1/64\" = 1'-0\"" "0.015625:12")
                      '("1\" = 10'-0\"" "1:120")
                      '("1\" = 20'-0\"" "1:240")
                      '("1\" = 25'-0\"" "1:300")
                      '("1\" = 30'-0\"" "1:360")
                      '("1\" = 40'-0\"" "1:480")
                      '("1\" = 50'-0\"" "1:600"))
           )
     (command "_.-scalelistedit" "a")
     (repeat (setq i (length ScaleList))
           (setq n (nth (setq i (1- i)) ScaleList))
           (command
                 (car n)
                 (cadr n)
                 (if (zerop i)
                       "e"
                       "a"))
           )
     (princ)
     )

Edited by pBe
Posted
and if i want to erase all inch scales?

 

What do you mean?

Posted

i want to keep only scales like 1:1, 1:10, 4:1....end to erase all

1/2\" = 1'-0 ... and the other inches scales...

Posted

Adding an item on Annoscale list is one thing, but deleting particualr named scale doesnt requrie a lisp code

 

But to give you an idea

 

(defun ScaleList (/ a)               
(foreach
          scle  (dictsearch (namedobjdict) "ACAD_SCALELIST")
         (if (= 350 (car scle))
           (setq a (cons (cdr (assoc 300 (entget (cdr scle)))) a)))
     a
         )
     )

 

This will give you the current scalelist, all you need to do is find the ones you want to delete and pass it on (command "_.-scalelistedit"....) similar to what i posted earlier

Posted

Seems to be a problem like this: (command "_.-scalelistedit" "d" "1/16" = 1'-0"" "e")

1/16" = 1'-0" between " " ... too many """"""

Posted
Seems to be a problem like this: (command "_.-scalelistedit" "d" "1/16" = 1'-0"" "e")

1/16" = 1'-0" between " " ... too many """"""

 

(command "_.-scalelistedit" "d" "1/16\" = 1'-0\"" "e");

 

 

(defun c:ErInch  (/ ScaleList)
(defun ScaleList  (/ a)
   (foreach
          scle
              (dictsearch (namedobjdict) "ACAD_SCALELIST")
         (if (= 350 (car scle))
               (setq a    (cons (cdr  (assoc
                                            300
                                            (entget
                                                  (cdr  scle))))
                                a)))
         a
         )
   )
     (foreach
            n  (ScaleList)
           (wcmatch n "*\"")
           (command "_.-scalelistedit" "_D" n "e")
           )
     (princ)
     )

 

Note: If a scale is current or supported by an annotative object, it cannot be deleted.

 

sample message:

Scale 1" = 1' is referenced so it cannot be deleted.

Posted
Good for you :)

 

Glad i could help

 

Thx on the scale list routine i have taken the liberty to modify it a little bit:

 

;;IS inserts or makes a scalelist.
(defun c:IS  ( / Scalelist i n)
     (setvar "cmdecho" 0)
     (setvar "expert" 5)
     (setq ScaleList
                (list
                      '("1:2" "1:2")
                      '("1:2.5" "1:2.5")
                      '("1:5" "1:5")
                      '("1:10" "1:10")
              '("1:20" "1:20")
              '("1:25" "1:25")
              '("1:50" "1:50")
              '("1:75" "1:75")
              '("1:100" "1:100")
              '("1:200" "1:200")    
              '("1:250" "1:250")
              '("1:500" "1:500")
              '("1:750" "1:750")
                      '("1:1000" "1:1000"))
           )
     (command "_.-scalelistedit" "a")
     (repeat (setq i (length ScaleList))
           (setq n (nth (setq i (1- i)) ScaleList))
           (command
                 (car n)
                 (cadr n)
                 (if (zerop i)
                       "e"
                       "a"))
           )
     (setvar "cmdecho" 1)
     (setvar "expert" 0)
     (princ)
     )

;;dsc deletes a entire scale list on dwg. 
(defun c:dsc ( / )
(setvar "cmdecho" 0)
(command "-scalelistedit" "d" "*" "e")
(Princ "Scaleliste removed from dwg") 
(princ)
(setvar "cmdecho" 1)
)

i have added a routine to delete the entire scale list of cause only useful when there is no annotation objects on scale list values. Mayby it is possible to make the scale routine further advance and add more commands.

 

elfert

Posted
(setvar 'Expert 5)

 

(defun c:IS_  ( / Scalelist i n)
     (setvar "cmdecho" 0)
     (setvar "expert" 5)
     (setq ScaleList
                (list
                      '("1:2" "1:2")
                      '("1:4" "1:4")
                      '("1:8" "1:8")
                      '("1\" = 1'-0\"" "1:12")
                      '("1/2\" = 1'-0\"" "0.5:12")
                      '("1/4\" = 1'-0\"" "0.25:12")
                      '("3/16\" = 1'-0\"" "0.01875:12")
                      '("1/8\" = 1'-0\"" "0.125:12")
                      '("3/32\" = 1'-0\"" "0.09375:12")
                      '("1/16\" = 1'-0\"" "0.0625:12")
                      '("1/32\" = 1'-0\"" "0.03125:12")
                      '("1/64\" = 1'-0\"" "0.015625:12")
                      '("1\" = 10'-0\"" "1:120")
                      '("1\" = 20'-0\"" "1:240")
                      '("1\" = 25'-0\"" "1:300")
                      '("1\" = 30'-0\"" "1:360")
                      '("1\" = 40'-0\"" "1:480")
                      '("1\" = 50'-0\"" "1:600"))
           )
     (command "_.-scalelistedit" "a")
     (repeat (setq i (length ScaleList))
           (setq n (nth (setq i (1- i)) ScaleList))
           (command
                 (car n)
                 (cadr n)
                 (if (zerop i)
                       "e"
                       "a"))
           )
     (princ)
     )

 

Thank you very much, that works great. Never new about "expert".

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...