Jump to content

Accessing Entities in a block


MartinSomerville

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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