Jump to content

Recommended Posts

Posted

I am trying to delete all the dimensions in a drawing, but I am stuck on how to accomplish this.

 

 
(defun C:edims ()
  (command "erase"(ssget (list (cons 0 "DIMENSION"))) "all" "")
  (princ)
)

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    5

  • ksperopoulos

    4

  • Tharwat

    4

  • pBe

    4

Posted

I think I got it. At least it seems to work.

 

 
(defun C:edims ()
  (command "erase" (ssget "x" (list (cons 0 "DIMENSION"))) "" (princ)
  )
)

Posted
I think I got it. At least it seems to work.

 

 
(defun C:edims ()
  (command "erase" (ssget "x" (list (cons 0 "DIMENSION"))) "" (princ)
  )
)

Hi.

The following codes will run with no ; error: bad argument value: AutoCAD command

as your codes are responding to command line, and you can check this out.

(defun C:edims (/ er)
  (setq er(ssget "_x" (list (cons 0 "DIMENSION"))))
(command "_erase" er "")
 (princ)
  ) 

:shock:

Regards.

Tharwar

Posted

Better to use the mask *DIMENSION. In Autocad 2008 add more ARC_DIMENSION

(defun C:edims (/ ss)
 (if (setq ss (ssget "_x" (list (cons 0 "[b][color="Red"]*[/color][/b]DIMENSION"))))
   (command "_erase" ss "")
   )
 (princ)
  )

Posted
Better to use the mask *DIMENSION. In Autocad 2008 add more ARC_DIMENSION

(defun C:edims (/ ss)
 (if (setq ss (ssget "_x" (list (cons 0 "[b][color="Red"]*[/color][/b]DIMENSION"))))
   (command "_erase" ss "")
   )
 (princ)
  )

 

Hi

I wonder what is the use of that astrisk.

 

Best Regards

Tharwat

Posted

The asterisk (*) means wildcard for any number of charachters prior to the word dimension.

 

I use it often to freeze furniture layers in an architectural drawing.

 

For example, type at command line:

 

(command "layer" "F" "*furn*" "")

 

all layers containing the letters 'furn' consecutively (in that order) will be frozen.

Posted
The asterisk (*) means wildcard for any number of charachters prior to the word dimension.

 

I use it often to freeze furniture layers in an architectural drawing.

 

For example, type at command line:

 

(command "layer" "F" "*furn*" "")

 

all layers containing the letters 'furn' consecutively (in that order) will be frozen.

 

Thanks for your explanations... but I tried also the following it worked as well as yours.

(command "layer" "F" "furn" "")

 

So what is the difference between both of them Please.

 

Regards

Tharwat

Posted
Better to use the mask *DIMENSION. In Autocad 2008 add more ARC_DIMENSION [/quote]

 

Good point! I have a pretty basic lisp question for a beginner though....what is the purpose for the (/ ss) after the function's name and do I need it if I am going to simply add the process of this lisp to another lisp as opposed to running it as its own command? Hope that makes sense.

Posted

names after / - local variables. The time of their lives - body functions (commands) to which they are defined

small example

(defun C:TEST1 ( )
 ;;;str - a global variable. It retains its value after the command
 (setq str (getstring "\nType any word: "))
 (princ "\nYou enter ")(princ str)
 (princ)
 )

(defun C:TEST2 (/ str1 )
 ;;;str1 - a local variable. It is removed after the completion of command
 (setq str1 (getstring "\nType any word: "))
 (princ "\nYou enter ")(princ str1)
 (princ)
 )

And Result

Command: test1

 

Type any word: TEST

 

You enter TEST

 

Command:

Command: !str

"TEST"

 

Command: test2

 

Type any word: TEST

 

You enter TEST

 

Command:

Command: !str1

nil

Posted
names after / - local variables. The time of their lives - body functions (commands) to which they are defined

small example

(defun C:TEST1 ( )
 ;;;str - a global variable. It retains its value after the command
 (setq str (getstring "\nType any word: "))
 (princ "\nYou enter ")(princ str)
 (princ)
 )

(defun C:TEST2 (/ str1 )
 ;;;str1 - a local variable. It is removed after the completion of command
 (setq str1 (getstring "\nType any word: "))
 (princ "\nYou enter ")(princ str1)
 (princ)
 )

And Result

 

really nice explanation , And I haven't known that way before.

 

But what about this function

(defun abc (o p q r / v w x y z)

Does it mean that they have to be supported with values before implementing

the defun function

 

Thanks

Tharwat

Posted

Thanks for the explanation VVA. So these would be needed if I were to include them in another lisp without the defun name to carry the variable through that command.

  • 1 year later...
Posted

Because it invokes a call to command function. it only "erase" objects on the current layout.

 

Quick mod:

(defun C:edims (/ ss)
 (if (setq ss (ssget "_x" (list (cons 0 "*DIMENSION"))))
      (repeat (sslength ss)
             (entdel (ssname ss 0))
             (ssdel (ssname ss 0) ss))
       )
 (princ)
  )

Posted

Another:

 

(defun c:deldims ( / d )
   (vlax-for b (vla-get-blocks (setq d (vla-get-activedocument (vlax-get-acad-object))))
       (if (eq :vlax-false (vla-get-isxref b))
           (vlax-for o b
               (if (wcmatch (vla-get-objectname o) "AcDb*Dimension*")
                   (vl-catch-all-apply 'vla-delete (list o))
               )
           )
       )
   )
   (vla-regen d acallviewports)
   (princ)
)
(vl-load-com) (princ)

Will delete all Dimension types found in all layouts and in all blocks and nested blocks.

 

Will omit Dimensions in XRefs and on locked layers.

Posted

 

(vl-catch-all-apply 'vla-delete (list o))

 

.....and on locked layers.

 

Clever, I wonder why vla-** behaves that way, (i mean errors) when encountering locked layers as compared to entdel/entmod thingy which ( appears to) breeze thru them as if nothing happens... ?

Posted
I wonder why vla-** behaves that way, (i mean errors) when encountering locked layers as compared to entdel/entmod thingy which ( appears to) breeze thru them as if nothing happens... ?

 

entdel / entmod will still fail to delete / modify entities on locked layers, however, when these functions fail they return nil rather than error. When Visual LISP functions fail, they cause an exception to occur.

 

Compare the behaviour of:

 

AutoLISP                 Visual LISP
------------------------------------------
entdel                   vla-delete
entmod                   vlax-put-property
tblsearch / dictsearch   vla-item
etc.

Posted

....rather than error. When Visual LISP functions fail, they cause an exception to occur.

 

Got it. Thanks Lee

 

Cheers :)

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...