dhl Posted October 28, 2009 Author Share Posted October 28, 2009 To get the total items of a list use (length ss) instead of sslength. I found the "14W" by scouring the dxf data in AutoCAD's Vlide editor. That's how I would suggest looking deeper into these objects if necessary. Any code that contains an ename, you can perform an entget on and see more nested data. Here's a little example: I'm not quite sure of how you did what did in the attached screendump, and I'm still struggling a bit with how to extract style names. What I'm trying to do: 1. Click on a device and extract the device name from this entsel (eg 14) 2. Use this device name to create a selection filter 3. select an area with this filter (eg ssget "w" pt1 pt2 devicenamefilter) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 28, 2009 Share Posted October 28, 2009 I'm not quite sure of how you did what did in the attached screendump, and I'm still struggling a bit with how to extract style names. What I'm trying to do: 1. Click on a device and extract the device name from this entsel (eg 14) 2. Use this device name to create a selection filter 3. select an area with this filter (eg ssget "w" pt1 pt2 devicenamefilter) Try this....though being that i don't have MEP I cannot guarantee it will work (defun c:filterdevice (/ dic e fltr n out ss) (princ "\nSelect device to set filter: ") (setq out (ssadd)) (if (and (setq n -1) (setq ss (ssget ":S" '((0 . "AECB_DEVICE")))) (setq e (ssname ss 0)) (setq e (member '(102 . "AECB_CONNECTION_COMPONENTS}") (entget e))) (setq e (cdr (cadr e))) (= (type e) 'ename) (setq fltr (cdr (cadr (vl-remove-if-not '(lambda (x) (= 3 (car x))) (entget e)))) ) ) (if (setq dic (cdr (cadr (member '(3 . "AECB_DEVICE_STYLES") (entget (namedobjdict))))) ) (if (setq dic (cdr (cadr (member (cons 3 fltr) (entget dic))))) (if (setq ss (ssget '((0 . "AECB_DEVICE")))) (while (setq e (ssname ss (setq n (1+ n)))) (if (member (cons 341 dic) (entget e)) (setq out (ssadd e out)) ) ) ) ) ) ) (sssetfirst nil out) (princ) ) Quote Link to comment Share on other sites More sharing options...
dhl Posted October 30, 2009 Author Share Posted October 30, 2009 Try this....though being that i don't have MEP I cannot guarantee it will work Fortunate you added your disclaimer, cause this routine shut down mep not sure why though... Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 30, 2009 Share Posted October 30, 2009 Fortunate you added your disclaimer, cause this routine shut down mep not sure why though... That is strange it shut you down...the code is essentially the same as the previous only with an entsel to grab the device name. Does it consistently kick you out of CAD or was it a one time fluke? Quote Link to comment Share on other sites More sharing options...
dhl Posted October 30, 2009 Author Share Posted October 30, 2009 That is strange it shut you down...the code is essentially the same as the previous only with an entsel to grab the device name. Does it consistently kick you out of CAD or was it a one time fluke? It seems to be pretty consistent in Meo 2009, however in 2008 it seems to work, oddly enough... Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 30, 2009 Share Posted October 30, 2009 It seems to be pretty consistent in Meo 2009, however in 2008 it seems to work, oddly enough... I somewhat tested the code in AutoCAD with an object enabler. Not sure what is causing the problem and without MEP troubleshooting is a bit hard. Sorry. Quote Link to comment Share on other sites More sharing options...
dhl Posted November 2, 2009 Author Share Posted November 2, 2009 I somewhat tested the code in AutoCAD with an object enabler. Not sure what is causing the problem and without MEP troubleshooting is a bit hard. Sorry. No problem ronjonp. Your help is still very valueable to me. With some inspiration from your original code (defun devicefilter() (setq ent (car (entsel))) (setq ent (member '(102 . "AECB_CONNECTION_COMPONENTS}") (entget ent))) (setq filter (assoc 341 ent)) (setq ss (ssget "x" filter)) ) EDIT: Done some more coding. I've got to the conclusion that dxf code 341, following (102 . "AECB_CONNECITON_COMPONENTS}") contains the device style entity name. What I can't understand is why my selection filter (ssget "x" filter) doesn't work. What have I done wrong? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.