Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SSGET

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
PencilsWereSoEasy
823 Views, 10 Replies

SSGET

i've been looking for a way to get QSELECT functionality in an automated form (like Actions) so i can select hatches with a particular pattern and flip them to a new pattern, but i'm having problems understanding the syntax of SSGET.

 

looking at the help page:

http://docs.autodesk.com/ACD/2013/ENU/index.html?url=files/GUID-0F37CC5E-1559-4011-B8CF-A3BA0973B2C3...

 

they give the syntax as:

(ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list])

 

but then the examples all suggest something more like (ssget "[sel-method]" '([pt1 [pt2]] [pt-list] [filter-list]))

 

what's the syntax for filter lists?  i want to select all hatches with pattern DOTS (and then change to pattern SOLID).  any help??

 

thanks in advance!


______________________________
~ "if this were /. this would be funny"
10 REPLIES 10
Message 2 of 11
dbroad
in reply to: PencilsWereSoEasy

(ssget "x" '((0 . "hatch") (2 . "dots"))) will select all hatch patterns in the drawing with the pattern name dots.

 

To change all dots hatches to solids, something like this would work.

 

(defun c:test ( / ss e ei)
(repeat (sslength (setq ss (ssget "x" '((0 . "HATCH")(2 . "DOTS")))))
(setq e (ssname ss 0) ei (entget e))
(ssdel e ss)
(entmod (subst '( 2 . "SOLID") (assoc 2 ei) ei))
)

(princ))

Architect, Registered NC, VA, SC, & GA.
Message 3 of 11
PencilsWereSoEasy
in reply to: dbroad

that's awesome, thank you so much!

 

so a few questions, 

 

(ssget "x" '((0 . "HATCH")(2 . "DOTS")))

 

i understand issue the SSGET command and use the X method to search the entire db, but then the 0 and the 2 - are those codes that indicate entity type (hmm, maybe a property??)  i assume so.

 

and is the . a delimiter that basically makes the statement say "take property 0 (maybe 0 is all entities??) and filter out anything that is "HATCH", then from that set, look at property 2 (pattern name) and filter it further for matches of "DOTS".

 

is this correct?

 

i realize i can prob get this online (and i just did download the LISP reference guide, but i figure i'll post this follow up in case it's helpful to anyone else)

 

thanks again!

 

EDIT:

started with this:

http://docs.autodesk.com/ACDMAC/2013/ENU/PDFs/acdmac_2013_autolisp_reference_guide.pdf

 

that lead me to this:

http://docs.autodesk.com/ACDMAC/2013/ENU/PDFs/acdmac_2013_autolisp_developers_guide.pdf

 

then to this:

http://images.autodesk.com/adsk/files/acad_dxf0.pdf

(the 16th page or page 6)


______________________________
~ "if this were /. this would be funny"
Message 4 of 11
dbroad
in reply to: PencilsWereSoEasy

If you want to find out what the codes mean, you might look at the dxf reference for autocad.  In AutoCAD help search box, type "DXF" without the quotes.  Then choose the entities section.  Click on common codes to obtain those or insert to obtain the insert codes.

 

Association lists are the way AutoLISP entity access functions get and put those object properties. They are  lists of key/value pairs.  Each key/value pair is stored as a dotted list.  (key . value).  The period must have whitespace on both sides.  The key is a DXF code.  The value varies.  Some properties are strings (surrounded by quotes).  Others can be numeric or point data.

 

You can experiment with looking up data by using 

 

(entget(car(entsel)))

 

Enter the above and select an object.  View the resulting data.

 

entget, entmod, subst, and assoc are a few frequently used entity data functions.  SSGET uses association list filters. 

 

The references you cited are good places to start learning.   Thanks for the kudo.  Glad it worked for you.

Architect, Registered NC, VA, SC, & GA.
Message 5 of 11

I know its too late but

(defun c:test ( / ad ) (vl-load-com)
  (foreach space
    (list (vla-get-modelspace (setq ad (vla-get-ActiveDocument (vlax-get-acad-object))))
      (vla-get-paperspace ad)
    )
    (vlax-for i space
      (and (eq "AcDbHatch" (vla-get-objectname i))
        (eq (strcase (vla-get-patternName i)) "DOTS")
        (vla-setpattern i acHatchPatternTypePreDefined "SOLID")
      )
    )
  )
)

 

_____

Reid B.
_____
Acad 2015
Architecture 2010
Message 6 of 11

hey Reid, what are the advantages to your code?


______________________________
~ "if this were /. this would be funny"
Message 7 of 11

Just showing an alternative. It might be faster...? I don't know. There are several ways to accomplish your goal. I posted it just for fun

_____

Reid B.
_____
Acad 2015
Architecture 2010
Message 8 of 11

gotcha - thank you for the additional input. you guys are what makes the internet awesome 🙂

______________________________
~ "if this were /. this would be funny"
Message 9 of 11
dbroad
in reply to: REID7800

Reid,

It would be extremely unlikely that that code would be faster due to the efficiency of the selectionset mechanism.  Having to parse every element at the top level to determine whether it was hatch or not would be generally slower than to use selection sets.  In addition, your code would overlook any layout that was not the the current paperspace.  

 

ActiveX would shine however if you needed to change hatch nested into blocks in addition to those in the main modelspace and layout blocks.  Such as:

 

(vl-load-com)
(defun c:test ( / doc)
(vlax-for b (vla-get-blocks
	      (setq doc
	      (vla-get-activedocument
		(vlax-get-acad-object))))
  (vlax-for o b
    (if (and
	  (= "AcDbHatch" (vla-get-objectname o))
	  (= "DOTS" (strcase (vla-get-PatternName o))))
      (vla-setpattern o acHatchPatternTypePreDefined "solid")
      ))
  )
  (vla-regen doc acallviewports)
  (princ)
  )

 

Architect, Registered NC, VA, SC, & GA.
Message 10 of 11
REID7800
in reply to: dbroad

Don't forget the ability to get/put dynamic block properties 🙂
_____

Reid B.
_____
Acad 2015
Architecture 2010
Message 11 of 11
dbroad
in reply to: REID7800

Very true, that too.  Although that topic was a bit out of scope of the OP's immediate needs.

Architect, Registered NC, VA, SC, & GA.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost