Author Topic: Removing objects in lisp  (Read 7510 times)

0 Members and 1 Guest are viewing this topic.

AfricaAD

  • Guest
Removing objects in lisp
« on: July 05, 2005, 05:37:13 PM »
Is there a variable or string of code which will automatically remove objects in lisp, particularly hatch patterns?

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Removing objects in lisp
« Reply #1 on: July 05, 2005, 06:10:03 PM »
Sure, but Quick select in the Properties toolbox works well, too.

Did you want ALL hatches deleted, or such certain ones?

AfricaAD

  • Guest
Removing objects in lisp
« Reply #2 on: July 06, 2005, 01:38:25 PM »
I am looking for a way to do it in lisp. I created a display order routine that is specific to my company & would like a way in lisp to remove certain layers & hatches/objects from the selection set.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Removing objects in lisp
« Reply #3 on: July 06, 2005, 02:08:04 PM »
OK, so you get a selection set and you want to exclude certain things from the SS. Look into the wildcard matching functions of (ssget).

For instance, if you are selecting everything with (ssget "x"), you can omit layer "XREFS" from the ss like this: (ssget "x" '((8 . "~XREFS")))
Note the tilde "~", per the description under (wcmatch): If it is the first character in the pattern, it matches anything except the pattern.

If you want to exclude only certain objects, you can use (ssdel) once you have the ss.

Be a bit more specific, such as showing the code and exactly what you are trying to accomplish, and I might be able to be a bit more helpful.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Removing objects in lisp
« Reply #4 on: July 06, 2005, 02:09:13 PM »
(ssdel ename ss)
Deletes an object (entity) from a selection set

Jeff, beat me to it. 8)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

AfricaAD

  • Guest
Removing objects in lisp
« Reply #5 on: July 06, 2005, 07:20:24 PM »
Here is the lisp. Some hatch patterns are on different layers:

Code: [Select]


(defun C:cbd (/ llyr)
  (setq llyr (getvar "clayer"))
  (setvar "clayer" "0")
  (command "-layer" "state" "s" "temp" "" "" "t" "*" "on" "*" "u" "*" "lo" "-pouche" "lo" "-pouche253" "lo" "-hat" "lo" "defpoints" "")
  (command "copybase" "0,0" "all" "")
  (command "erase" "p" "")
  (command "pasteclip" "0,0")
  (command "-layer" "lo" "*" "u" "-dims" "u" "-txt" "")
  (command "copybase" "0,0" "all" "")
  (command "erase" "p" "")
  (command "pasteclip" "0,0")
  (command "regen")
  (command "-layer" "state" "r" "temp" "delete" "temp" "" "lo" "defpoints" "lo" "-xref" "")
  (setvar "clayer" llyr)
  (princ)
)



So, to add the selection set code, would I add something like this:

Code: [Select]

(defun C:cbd (/ llyr)
  (setq ss (ssget))
  (setq llyr (getvar "clayer"))
  (setvar "clayer" "0")
  [i](some code here)[/i]
  (ssdel "SOLID" ss)
  [i](more code)[/i]
)

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Removing objects in lisp
« Reply #6 on: July 06, 2005, 07:58:26 PM »
Heh, we're getting closer :)
Not having a drawing with all of the pertinent layers and objects I cannot test this, but I'm pretty sure it will do what you want. You can add/remove from the filters any other layers/objects/patternsyou want.
Code: [Select]

(defun C:cbd (/ llyr ss)
  (setq llyr (getvar "clayer"))
  (setvar "clayer" "0")
  ;(command "-layer" "state" "s" "temp" "" "" "t" "*" "on" "*" "u" "*" "lo" "-pouche" "lo" "-pouche253" "lo" "-hat" "lo" "defpoints" "")
  (setq ss (ssget "x"
 '((-4 . "<NOT")
   (-4 . "<OR")
   (2 . "SOLID");Add your Hatch patterns to exclude to this line
   (8 . "-pouche,-pouche253,-hat,defpoints")
   ;(0 . "HATCH");remove the first ; if you want ALL hatches excluded and remove the hatch names above
   (-4 . "OR>")
   (-4 . "NOT>")
   )
 )
)
  (command "copybase" "0,0" ss "")
  (command "erase" ss "")
  (command "pasteclip" "0,0")
  ;(command "-layer" "lo" "*" "u" "-dims" "u" "-txt" "")
  (setq ss (ssget "x" '((8 . "-dims,-txt"))))
  (command "copybase" "0,0" ss "")
  (command "erase" ss "")
  (command "pasteclip" "0,0")
  (command "regen")
  ;(command "-layer" "state" "r" "temp" "delete" "temp" "" "lo" "defpoints" "lo" "-xref" "")
  (setvar "clayer" llyr)
  (princ)
)

AfricaAD

  • Guest
Removing objects in lisp
« Reply #7 on: July 08, 2005, 01:13:05 PM »
I kinda of see what it is doing here. In this section:

Code: [Select]

  (setq ss (ssget "x"
        '((-4 . "<NOT")
          (-4 . "<OR")
          (2 . "SOLID");Add your Hatch patterns to exclude to this line
          (8 . "-pouche,-pouche253,-hat,defpoints")
          ;(0 . "HATCH");remove the first ; if you want ALL hatches excluded and remove the hatch names above
          (-4 . "OR>")
          (-4 . "NOT>")
          )
        )
   )


I am assuming the numerical values are intended for the "x" variable?

How are these numerical values related to objects & such? For example, if I were to add a line with a value of "6" to define specific blocks, will this work or is this value assigned to a specific function?

Now that afralisp closed, is there another good place I can go?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Removing objects in lisp
« Reply #8 on: July 08, 2005, 01:43:01 PM »
No! not a number at all.
See this explanation. <---<<  correction from this expiation.
Code: [Select]
;;  This one will exclude any object on the layers listed and any Solid Hatches
(setq ss
         (ssget      ; Get a selection set
           "x"  ; Entire database. If you specify the X selection method and do not provide a filter-list,
                ;; ssget selects all entities in the database, including entities on layers that are off,
                ;;  frozen, and out of the visible screen.
         ;;   ssget Filter follows
        '((-4 . "<NOT") ; start of NOT, the following are exculded from the selection set
          (-4 . "<OR")  ; Start of OR, any match of any of the following will be excluded
          (2 . "SOLID") ; any "SOLID" Hatch patterns will be excluded
          (8 . "-pouche,-pouche253,-hat,defpoints") ; anything on these layers are excluded
          (-4 . "OR>")
          (-4 . "NOT>")
          )
        )
   )


;;  Here is one the excludes only Solid pattern Hatchs on the layers listed.
  (setq ss
         (ssget      ; Get a selection set
           "x"  ; Entire database. If you specify the X selection method and do not provide a filter-list,
                ;; ssget selects all entities in the database, including entities on layers that are off,
                ;;  frozen, and out of the visible screen.
                ;;   ssget Filter follows
        '((-4 . "<NOT") ; start of NOT, the following are exculded from the selection set
          (-4 . "<AND")  ; Start of AND, to match objects must meet all of the following to be excluded
          (2 . "SOLID")
          (0 . "HATCH")
          (8 . "-pouche,-pouche253,-hat,defpoints")
          (-4 . "AND>")
          (-4 . "NOT>")
          )
        )
   )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Removing objects in lisp
« Reply #9 on: July 08, 2005, 05:27:59 PM »
Hmmm, CAB.....
Quote from: wordreference.com
expiation, atonement, propitiation
       the act of atoning for sin or wrongdoing (especially appeasing a deity)
;)
Africad, the numbers in the filter list refer to the DXF association Group code. As Alan has gone through and labelled what each one is for in this example......you can find the others and how to use them in the DXF section of the Developer's Reference (in the VLIDE press F1  to access it) Also se "Selection Set Filtering" in the same reference.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Removing objects in lisp
« Reply #10 on: July 08, 2005, 06:02:03 PM »
You can nevre trsut thsoe splel chekcers.:oops:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

AfricaAD

  • Guest
Removing objects in lisp
« Reply #11 on: July 08, 2005, 06:05:18 PM »
Thanks for the help! I'll check that out.