Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Attributed Objects (viewports - dimensions - leaders)

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
390 Views, 9 Replies

Attributed Objects (viewports - dimensions - leaders)

I am noticing something very, very strange here. Attributes
are "appearing" as subentities where they shouldn't be.

In the attached sample drawing ("test.dwg") use the following
code and select the viewport, a dimension, or a leader and
look at the resulting list. Seems that some leaders will return
a list and some won't.

This sample drawing was part of a sheet set and this view
was placed via the SSM.


These are the results I get:

Command: (nents (car (entsel)) "attrib")

"VIEWPORT" (
7ec20ac0> )

Command: (nents (car (entsel)) "attrib")
"DIMENSION" (
7eccecb8> )

Command: (nents (car (entsel)) "attrib")
"LEADER" (
7eccee70> )


Umm... how can a viewport, dimension, or a leader have attributes?
It is like these entities are linked to the "label block for views"
specified in the sheet set. Surely this is not acceptable behavior.

I get these results in 2007 and 2008. Anyone else confirm?


; Jason Piercey . June 2nd, 2003
; get list of sub entity names
; [ename] - entity name or vla-object - block, insert or polyline
; [filter] - string, re: wcmatch()
; return: list of enames or nil
; revised: July 10th, 2003 - accepts ename or vla-object
(defun nEnts (ename filter / data ent rtn)
(or (= 'ename (type ename))
(setq ename (vlax-vla-object->ename ename)) )
(setq filter (strcase filter))
(print (cdr (assoc 0 (entget ename)))); <-- added this today for giggles.
(while (and ename (setq ename (entnext ename)))
(setq data (entget ename))
(setq ent (cdr (assoc 0 data)))
(if (wcmatch ent filter)
(setq rtn (cons ename rtn)) )
(if (= "SEQEND" ent) (setq ename nil))
)
(reverse rtn)
)


--
Autodesk Discussion Group Facilitator
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

Jason,

I'm getting the same results: some return a list of enames and some return nil. Tested with AutoCAD 2007.
Message 3 of 10
Anonymous
in reply to: Anonymous

I don't follow.

If you repeatedly call (setq ename (entnext ename)) you can encounter any number of 'complex' entities followed by its subentities, and terminated by a SEQEND entity.

Your code doesn't check for a 66 (subentities follow) entry in the entity's data, and AFAIK, that's the only way to generically identify a 'complex' entity without specifically testing its type to see if its a heavy polyline or a block with attributes.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"Jason Piercey" wrote in message news:5800852@discussion.autodesk.com...
I am noticing something very, very strange here. Attributes
are "appearing" as subentities where they shouldn't be.

In the attached sample drawing ("test.dwg") use the following
code and select the viewport, a dimension, or a leader and
look at the resulting list. Seems that some leaders will return
a list and some won't.

This sample drawing was part of a sheet set and this view
was placed via the SSM.


These are the results I get:

Command: (nents (car (entsel)) "attrib")

"VIEWPORT"
(
7ec20ac0> )

Command: (nents (car (entsel)) "attrib")
"DIMENSION" (
7eccecb8> )

Command: (nents (car (entsel)) "attrib")
"LEADER" (
7eccee70> )


Umm... how can a viewpor
t, dimension, or a leader have attributes?
It is like these entities are linked to the "label block for views"
specified in the sheet set. Surely this is not acceptable behavior.

I get these results in 2007 and 2008. Anyone else confirm?


; Jason Piercey . June 2nd, 2003
; get list of sub entity names
; [ename] - entity name or vla-object - block, insert or polyline
; [filter] - string, re: wcmatch()
; return: list of enames or nil
; revised: July 10th, 2003 - accepts ename or vla-object

(defun nEnts (ename filter / data ent rtn)
(or (= 'ename (type ename))
(setq ename (vlax-vla-object->ename ename)) )
(setq filter (strcase filter))
(print (cdr (assoc 0 (entget ename)))); <-- added this today for giggles.
(while (and ename (setq ename (entnext ename)))
(setq data (entget ename))
(setq ent (cdr (assoc 0 data)))
(if (wcmatch ent filter)
(setq rtn (cons ename rtn)) )
(if (= "SEQEND" ent) (setq ename nil))
)
(reverse rtn)
)


--
Autodesk Discus
sion Group Facilitator
Message 4 of 10
Anonymous
in reply to: Anonymous

Kelie,

Thanks for checking.

--
Autodesk Discussion Group Facilitator


wrote in message news:5801033@discussion.autodesk.com...
Jason,

I'm getting the same results: some return a list of enames and some return
nil. Tested with AutoCAD 2007.
Message 5 of 10
Anonymous
in reply to: Anonymous

I see what you are saying, Tony. Guess I never tested
that function very well with other entities than what I
expected to be passed as the ename. Time to revise.

Thanks.

--
Autodesk Discussion Group Facilitator


"Tony Tanzillo" wrote in message
news:5801208@discussion.autodesk.com...

> If you repeatedly call (setq ename (entnext ename)) you
> can encounter any number of 'complex' entities followed
> by its subentities, and terminated by a SEQEND entity.

> Your code doesn't check for a 66 (subentities follow)
> entry in the entity's data, and AFAIK, that's the only
> way to generically identify a 'complex' entity without
> specifically testing its type to see if its a heavy polyline
> or a block with attributes.
Message 6 of 10
Anonymous
in reply to: Anonymous

Jason,

Maybe like this in light of Tony's comments?

[code]
(defun nEnts2 (ename filter / data rtn)
(or (= 'ename (type ename))
(setq ename (vlax-vla-object->ename ename))
)
(setq filter (strcase filter))
(if (= 1 (cdr (assoc 66 (entget ename))))
(while
(and
(setq ename (entnext ename))
(setq data (entget ename))
(/= "SEQEND" (cdr (assoc 0 data)))
)
(if (wcmatch (cdr (assoc 0 data)) filter)
(setq rtn (cons ename rtn))
)
)
)
(reverse rtn)
) ;end
[/code]


"Jason Piercey" wrote in message
news:5801377@discussion.autodesk.com...
I see what you are saying, Tony. Guess I never tested
that function very well with other entities than what I
expected to be passed as the ename. Time to revise.

Thanks.

--
Autodesk Discussion Group Facilitator


"Tony Tanzillo" wrote in message
news:5801208@discussion.autodesk.com...

> If you repeatedly call (setq ename (entnext ename)) you
> can encounter any number of 'complex' entities followed
> by its subentities, and terminated by a SEQEND entity.

> Your code doesn't check for a 66 (subentities follow)
> entry in the entity's data, and AFAIK, that's the only
> way to generically identify a 'complex' entity without
> specifically testing its type to see if its a heavy polyline
> or a block with attributes.
Message 7 of 10
Anonymous
in reply to: Anonymous

Joe,

Your revision works. I wasn't thinking clearly (obviously)
when I started this thread yesterday.


--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5801465@discussion.autodesk.com...
Jason,

Maybe like this in light of Tony's comments?

[code]
(defun nEnts2 (ename filter / data rtn)
(or (= 'ename (type ename))
(setq ename (vlax-vla-object->ename ename))
)
(setq filter (strcase filter))
(if (= 1 (cdr (assoc 66 (entget ename))))
(while
(and
(setq ename (entnext ename))
(setq data (entget ename))
(/= "SEQEND" (cdr (assoc 0 data)))
)
(if (wcmatch (cdr (assoc 0 data)) filter)
(setq rtn (cons ename rtn))
)
)
)
(reverse rtn)
) ;end
[/code]
Message 8 of 10
Anonymous
in reply to: Anonymous

Jason,

How about you post a revised version. I felt a need to fix it because I've used your
function in a couple routines.

Thanks
Joe

"Jason Piercey" wrote in message
news:5801862@discussion.autodesk.com...
Joe,

Your revision works. I wasn't thinking clearly (obviously)
when I started this thread yesterday.


--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5801465@discussion.autodesk.com...
Jason,

Maybe like this in light of Tony's comments?

[code]
(defun nEnts2 (ename filter / data rtn)
(or (= 'ename (type ename))
(setq ename (vlax-vla-object->ename ename))
)
(setq filter (strcase filter))
(if (= 1 (cdr (assoc 66 (entget ename))))
(while
(and
(setq ename (entnext ename))
(setq data (entget ename))
(/= "SEQEND" (cdr (assoc 0 data)))
)
(if (wcmatch (cdr (assoc 0 data)) filter)
(setq rtn (cons ename rtn))
)
)
)
(reverse rtn)
) ;end
[/code]
Message 9 of 10
Anonymous
in reply to: Anonymous

Hi Joe,

Below is a revised function. I chose to test for specific
object types as just testing for dxf code 66 and a value
of 1 didn't work with block objects since that code is
absent from the definition. This seemed to work better
in my tests this morning.

; Jason Piercey . June 2nd, 2003
; get list of sub entity names
; [ename] - entity name or vla-object - block, insert or polyline
; [filter] - string, re: wcmatch()
; return: list of enames or nil
; revisions:
; July 10th, 2003
; - accepts ename or vla-object
;
; December 17th, 2007
; - restricted ename argument to block, insert, and polyline objects
; Thanks to Tony Tanzillo and Joe Burke

(defun nEnts (ename filter / data ent rtn)
(or (= 'ename (type ename))
(setq ename (vlax-vla-object->ename ename)) )

(setq filter (strcase filter))
(setq data (entget ename))
(setq ent (cdr (assoc 0 data)))
(if
(or (wcmatch ent "BLOCK,POLYLINE")
(and (= "INSERT" ent)
(= 1 (cdr (assoc 66 data))))
)
(while
(and
(setq ename (entnext ename))
(setq data (entget ename))
(setq ent (cdr (assoc 0 data)))
(/= "SEQEND" ent)
)
(if (wcmatch ent filter)
(setq rtn (cons ename rtn))
)
)
)
(reverse rtn)
)

--
Autodesk Discussion Group Facilitator


"Joe Burke" wrote in message
news:5802209@discussion.autodesk.com...
Jason,

How about you post a revised version. I felt a need to fix it because I've
used your
function in a couple routines.

Thanks
Joe
Message 10 of 10
Anonymous
in reply to: Anonymous

Thanks, Jason. Looks good.

Joe

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

Post to forums  

Autodesk Design & Make Report

”Boost