AutoCAD 2013/2014/2015

Reply
Valued Contributor
PencilsWereSoEasy
Posts: 55
Registered: ‎05-07-2012
Message 1 of 11 (241 Views)
Accepted Solution

SSGET

241 Views, 10 Replies
04-08-2014 03:00 PM

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"
*Expert Elite*
dbroad
Posts: 1,551
Registered: ‎08-16-2007
Message 2 of 11 (237 Views)

Re: SSGET

04-08-2014 03:12 PM 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))

Valued Contributor
PencilsWereSoEasy
Posts: 55
Registered: ‎05-07-2012
Message 3 of 11 (192 Views)

Re: SSGET

04-09-2014 07:01 AM 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"
*Expert Elite*
dbroad
Posts: 1,551
Registered: ‎08-16-2007
Message 4 of 11 (181 Views)

Re: SSGET

04-09-2014 09:49 AM 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.

Distinguished Contributor
REID7800
Posts: 182
Registered: ‎01-08-2010
Message 5 of 11 (176 Views)

Re: SSGET

04-09-2014 11:09 AM in reply to: PencilsWereSoEasy

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
Valued Contributor
PencilsWereSoEasy
Posts: 55
Registered: ‎05-07-2012
Message 6 of 11 (159 Views)

Re: SSGET

04-10-2014 06:20 AM in reply to: REID7800

hey Reid, what are the advantages to your code?


______________________________
~ "if this were /. this would be funny"
Distinguished Contributor
REID7800
Posts: 182
Registered: ‎01-08-2010
Message 7 of 11 (147 Views)

Re: SSGET

04-10-2014 07:44 AM in reply to: PencilsWereSoEasy

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
Valued Contributor
PencilsWereSoEasy
Posts: 55
Registered: ‎05-07-2012
Message 8 of 11 (140 Views)

Re: SSGET

04-10-2014 09:28 AM in reply to: REID7800
gotcha - thank you for the additional input. you guys are what makes the internet awesome :smileyhappy:

______________________________
~ "if this were /. this would be funny"
*Expert Elite*
dbroad
Posts: 1,551
Registered: ‎08-16-2007
Message 9 of 11 (133 Views)

Re: SSGET

04-10-2014 09:56 AM 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)
  )

 

Distinguished Contributor
REID7800
Posts: 182
Registered: ‎01-08-2010
Message 10 of 11 (125 Views)

Re: SSGET

04-10-2014 11:12 AM in reply to: dbroad
Don't forget the ability to get/put dynamic block properties :smileyhappy:
_____

Reid B.
_____
Acad 2015
Architecture 2010
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.