Author Topic: Hatch selection  (Read 3427 times)

0 Members and 1 Guest are viewing this topic.

pmvliet

  • Guest
Hatch selection
« on: January 03, 2006, 05:14:53 PM »
Hey everyone...

I'm gonna try and muddle thru and create a routine. We routinely do a lot of solid hatching with linework for either color elevations, presentations, floor patterning etc. I want to create a lisp routine that will scan the drawing for all solid hatching,
start draworder and send it to back.

From reading a little SSGET seems to be what I want? (SSGET "X") selects the entire drawing database. So I need
to add a filter list to give me just the hatch pattern of solid. The following will get me all hatches:
Code: [Select]
(DEFUN C:SOLIDBACK (/ SS2)
  (setq ss2 (ssget "X"
   '((0 . "HATCH"))
    )
  )
)

switching (0."hatch") to (2."solid) using the dxf group codes doesn't work...

what would be my other options?

Pieter



T.Willey

  • Needs a day job
  • Posts: 5251
Re: Hatch selection
« Reply #1 on: January 03, 2006, 05:18:11 PM »
This just worked for me.
(ssget '((0 . "HATCH")(2 . "SOLID")))

Does it not work for you?  You can change it so that it selects all objects.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: Hatch selection
« Reply #2 on: January 03, 2006, 05:44:54 PM »
Not tested yet:

Code: [Select]
(defun c:bh_2back (/bh_ents)
(setq bh_ents (ssget '((0 . "HATCH")(2 . "SOLID"))))
(command "draworder" bh_ents "b")
(princ)
)

 :-)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Hatch selection
« Reply #3 on: January 03, 2006, 06:26:54 PM »
Try this.....might give you some ideas:

Code: [Select]
(defun c:shb (/ ss)
  (if (setq ss (ssget "x" '((0 . "HATCH") (2 . "SOLID"))))
    (command ".draworder" ss "" "back")
    (alert "\n No solid hatches found!")
  )
  (princ)
)

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
Re: Hatch selection
« Reply #4 on: January 03, 2006, 06:39:26 PM »
So I can link (0."hatch") and (2."solid") together? kewl...  :-D

ok, so I understand everything, what does  ` <<---- do in the code for ssget?

Thanks,
I'll be adding to this... I'm gonna use your codes as reference...

Pieter

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Hatch selection
« Reply #5 on: January 03, 2006, 06:46:30 PM »
ok, so I understand everything, what does ` <<---- do in the code for ssget?

From my understanding.
The ' marks tell Acad to interpret what follows as it is.  That is why when you have a varialbe, you have to use list instead of '.

ie.
Code: [Select]
(ssget '((0 . "hatch") (2 . "solid")))
is the same as
Code: [Select]
(setq ObjType "hatch" PatName "solid)
(ssget (list (cons 0 ObjType) (cons 2 PatName)))
but you could not use
Code: [Select]
(setq ObjType "hatch" PatName "solid)
(ssget '((0 . ObjType) (2 . PatName)))
because it would interpret the variable ObjType as the type of object you are looking for.

Hope that clears things up a little.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

pmvliet

  • Guest
Re: Hatch selection
« Reply #6 on: January 03, 2006, 07:35:47 PM »
ok....
Got it to work. Maybe I had another typo, but it seems that to put this into an IF statement the "X"
needs to be there...

last question about this
Code: [Select]
(princ)I've seen this in lots of code, but what does it do... I know silly question but for the code I write, I want to understand.
I just don't see any difference at the command line.

Thanks

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Hatch selection
« Reply #7 on: January 04, 2006, 12:29:55 AM »
All lisp routines will return the last evaluated expression....so based on the help file's description for Exiting Quietly:
Quote
Exiting Quietly
If you invoke the princ function without passing an expression to it, it displays nothing and has no value to return. So if you write an AutoLISP expression that ends with a call to princ without any arguments, the ending nil is suppressed (because it has nothing to return). This practice is called exiting quietly.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: Hatch selection
« Reply #8 on: January 04, 2006, 11:23:54 AM »
In addition to Tim's replay... You can also mix between cons and quoted:
Code: [Select]
(setq PatName "SOLID")
(list '(0 . "HATCH") (cons 2 PatName))
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

pmvliet

  • Guest
Re: Hatch selection
« Reply #9 on: January 04, 2006, 05:17:17 PM »
Thanks Everyone!

I learned a little... now for my next routine...

Pieter