Jump to content

Qselect


dhl

Recommended Posts

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)

Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • dhl

    12

  • ronjonp

    10

  • Shawndoe

    3

  • alanjt

    2

Top Posters In This Topic

Posted Images

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 :P

 

(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)
)

Link to comment
Share on other sites

Try this....though being that i don't have MEP I cannot guarantee it will work :P

 

 

Fortunate you added your disclaimer, cause this routine shut down mep :D not sure why though...

Link to comment
Share on other sites

Fortunate you added your disclaimer, cause this routine shut down mep :D 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?

Link to comment
Share on other sites

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... :?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...