Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
azrdgldr
Posts: 1,250
Registered: ‎01-09-2007
Message 1 of 5 (253 Views)
Accepted Solution

Extract Assoc 341?

253 Views, 4 Replies
07-29-2011 07:34 AM

I am trying to extract assoc 41 (shown in red) on following entity list: I tried to extract the assoc 341 first, thinking this is the entity name but I get <Entity name: 0> and not <Entity name: 7ee38f30> which is what I expect.  I am missing something here.  What?  Thanks for any help you can give.

 

Command: (setq hrhl (entget hrh))
((-1 . <Entity name: 7ee410d8>) (0 . "MULTILEADER") (330 . <Entity name:
7ee38fb8>) (5 . "93") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0")
(100 . "AcDbMLeader") (270 . 2) (300 . "CONTEXT_DATA{") (40 . 1.0) (10 3.11928
4.12382 0.0) (41 . 0.18) (140 . 0.18) (145 . 0.09) (174 . 1) (175 . 6) (176 .
0) (177 . 0) (290 . 0) (296 . 0) (110 2.44763 2.52259 0.0) (111 1.0 0.0 0.0)
(112 0.0 1.0 0.0) (297 . 0) (302 . "LEADER{") (290 . 1) (291 . 1) (10 3.11928
4.12382 0.0) (11 1.0 0.0 0.0) (90 . 0) (40 . 0.36) (304 . "LEADER_LINE{") (10
2.44763 2.52259 0.0) (91 . 0) (170 . 1) (92 . -1056964608) (340 . <Entity name:
0>) (171 . -2) (40 . 0.0) (341 . <Entity name: 0>) (93 . 0) (305 . "}") (271 .
0) (303 . "}") (272 . 9) (273 . 9) (301 . "}") (340 . <Entity name: 7ee38f90>)
(90 . 1024) (170 . 1) (91 . -1056964608) (341 . <Entity name: 7ee38f30>) (171 .
-2) (290 . 1) (291 . 1) (41 . 0.36) (42 . 0.18) (172 . 0) (343 . <Entity name:
7ee38f00>) (173 . 1) (95 . 6) (174 . 1) (175 . 0) (92 . -1056964608) (292 . 0)
(93 . -1056964608) (10 1.0 1.0 1.0) (43 . 0.0) (176 . 0) (293 . 0) (294 . 0)
(178 . 0) (179 . 1) (45 . 1.0) (271 . 0) (272 . 9) (273 . 9))

Valued Mentor
Shneuph
Posts: 327
Registered: ‎11-26-2007
Message 2 of 5 (243 Views)

Re: Extract Assoc 341?

07-29-2011 08:51 AM in reply to: azrdgldr

I don't think you need to entity name of the 341 assoc list first.  It's returning the first 341 list in the mleader entity which is ename 0 insinde the (304 . LEADER_LINE{) list.  The one you're looking at is the 2nd 341 list.  Regardless... you shoudln't need it. 

 

You COULD reverse the list and use assoc 41.. I wouldn't count on this working consistently though with many different mleaders...

 

Try:

(setq yourvariable (assoc 41 (reverse (entget hrh))))

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
*Expert Elite*
azrdgldr
Posts: 1,250
Registered: ‎01-09-2007
Message 3 of 5 (236 Views)

Re: Extract Assoc 341?

07-29-2011 09:02 AM in reply to: Shneuph

Thanks for your reply.  It worked.  I didn't see the first 341 that you pointed out.

*Expert Elite*
Kent1Cooper
Posts: 5,293
Registered: ‎09-13-2004
Message 4 of 5 (227 Views)

Re: Extract Assoc 341?

07-29-2011 10:55 AM in reply to: azrdgldr

Another way to get the second entry under a particular DXF code, for example if there might be more than two [meaning that getting the first one in the reversed list would get you the last such entry, not the second one], is this [using your DXF code and entity data variable name]:

 

(cdr (assoc 41 (cdr (member (assoc 41 hrhl) hrhl))))

 

It makes a new list of everything after the first such entry, and then gets the information from the first one in that new list.

 

I use that approach to get entity types sometimes, if I want to be able to distinguish "heavy" 2D Polylines from 3D Polylines.  You can't tell them apart from their basic entity-type (assoc 1) values [they're both "POLYLINE"], so I go for the second (assoc 100) value, which does distinguish them.  And likewise to distinguish different varieties of Dimensions, or similarly with (assoc 10) if you have a reason to want the second vertex of a Polyline, etc.  [There are also other ways to such information....]

Kent Cooper
*Expert Elite*
azrdgldr
Posts: 1,250
Registered: ‎01-09-2007
Message 5 of 5 (223 Views)

Re: Extract Assoc 341?

07-29-2011 11:30 AM in reply to: Kent1Cooper

You say you ain't Da' Man but in some instances you are Da' Man.  Have a good weekend.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community