PDA

View Full Version : Accessing Entities in a block



MartinSomerville
25th May 2009, 04:10 am
Hi

Just wondering how I can do this?

Application could be to isolate all the layers within the block, for example.

I have poked around in the entget and dumped the block object but I can't really figure out how to get a list of entities.

I am very limited in xdata and dictionaries so am guessing the info is stored there.

Let me know if I haven't been clear enough.

Any help would be great

Thanks
Martin


((-1 . <Entity name: 7ef06410>) (0 . INSERT) (5 . 253A) (102 .
{ACAD_XDICTIONARY) (360 . <Entity name: 7ef06538>) (102 . }) (330 . <Entity
name: 7ef01cb8>) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . 0) (100 .
AcDbBlockReference) (2 . ms-block) (10 0.0 0.0 0.0) (41 . 1.0) (42 . 1.0) (43 .
1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))


; Application (RO) = #<VLA-OBJECT IAcadApplication 00cbef78>
; Document (RO) = #<VLA-OBJECT IAcadDocument 016f6d08>
; EffectiveName (RO) = "ms-block"
; Handle (RO) = "253A"
; HasAttributes (RO) = 0
; HasExtensionDictionary (RO) = -1
; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0a6b7604>
; InsertionPoint = (0.0 0.0 0.0)
; InsUnits (RO) = "Unitless"
; InsUnitsFactor (RO) = 1.0
; IsDynamicBlock (RO) = 0
; Layer = "0"
; Linetype = "BYLAYER"
; LinetypeScale = 1.0
; Lineweight = -1
; Material = "ByLayer"
; Name = "ms-block"
; Normal = (0.0 0.0 1.0)
; ObjectID (RO) = 2129683472
; ObjectName (RO) = "AcDbBlockReference"
; OwnerID (RO) = 2129665208
; PlotStyleName = "ByLayer"
; Rotation = 0.0
; TrueColor = #<VLA-OBJECT IAcadAcCmColor 2126b740>
; Visible = -1
; XEffectiveScaleFactor = 1.0
; XScaleFactor = 1.0
; YEffectiveScaleFactor = 1.0
; YScaleFactor = 1.0
; ZEffectiveScaleFactor = 1.0
; ZScaleFactor = 1.0
; Methods supported:
; ArrayPolar (3)
; ArrayRectangular (6)
; ConvertToAnonymousBlock ()
; ConvertToStaticBlock (1)
; Copy ()
; Delete ()
; Explode ()
; GetAttributes ()
; GetBoundingBox (2)
; GetConstantAttributes ()
; GetDynamicBlockProperties ()
; GetExtensionDictionary ()
; GetXData (3)
; Highlight (1)
; IntersectWith (2)
; Mirror (2)
; Mirror3D (3)
; Move (2)
; ResetBlock ()
; Rotate (2)
; Rotate3D (3)
; ScaleEntity (2)
; SetXData (2)
; TransformBy (1)
; Update ()

MartinSomerville
25th May 2009, 05:22 am
http://www.cadtutor.net/forum/showthread.php?t=36100

just found this.

haven't checked it out yet

Lee Mac
25th May 2009, 01:02 pm
That link should help you yes.

Just wondering, if this application is for layer isolation, you could also investigate "nentsel":



(defun c:bLayIso (/ sEnt)
(vl-load-com)
(if (setq sEnt (car (nentsel "\nSelect Sub-Entity: ")))
(vlax-for lay
(vla-get-layers
(vla-get-ActiveDocument
(vlax-get-acad-object)))
(or (eq (vla-get-Name lay) (cdr (assoc 8 (entget sEnt))))
(vla-put-layeron lay :vlax-false))))
(princ))

MartinSomerville
25th May 2009, 01:35 pm
thanks lee.
I ended up nutting something out with the help from that link ( I think one of yours too). Just with entsel and auto lisp though, using the tblobjname and entnext functions basically. Next step maybe is to do as ssget and incorporate a temp layer state to head back to with a sister unisolate (I guess akin with layiso and layuniso or whatever they are)

Haven't used nentsel so don't know how differs to entsel. Will checkout tomorrow at work.

yeah, although I'm not convinced I understand totally how your posted vlisp works (the 'or' kinda threw me - I don't think I've used it that way - kinda like a cond?), it looks like it just compares the selected entity name to the entire layer list one by one. If the layer (lay) name equals the selected entity layer name then it does nothing but if doesn't equal then it turns it off to keep true to the 'or'.

Thanks again
Cheers,
Martin

Lee Mac
25th May 2009, 02:13 pm
Haven't used nentsel so don't know how differs to entsel. Will checkout tomorrow at work.

nentsel provides direct access to the sub-entites in the entity - it returns a list similar to entsel, however with the ename of the sub-entity.



yeah, although I'm not convinced I understand totally how your posted vlisp works (the 'or' kinda threw me - I don't think I've used it that way - kinda like a cond?), it looks like it just compares the selected entity name to the entire layer list one by one. If the layer (lay) name equals the selected entity layer name then it does nothing but if doesn't equal then it turns it off to keep true to the 'or'.

Spot on mate -
I use "or" as opposed to (if (not... just because I like how concise it is.
The vlax-for just cycles through all the layers in the layer collection, and then, for each of the layers, the "or" statement compares the layer name, - hence if the layer name is not equal to that selected, it will turn it off.

Hope this helps somewhat,

Lee