+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Full Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Posts
    44

    Default Accessing Entities in a block

    Registered forum members do not see this ad.

    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

    Code:
    ((-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))
    Code:
    ;   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 ()

  2. #2
    Full Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Posts
    44

    Default

    http://www.cadtutor.net/forum/showthread.php?t=36100

    just found this.

    haven't checked it out yet

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    That link should help you yes.

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

    Code:
    (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))
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  4. #4
    Full Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Posts
    44

    Default

    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

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by MartinSomerville View Post
    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.

    Quote Originally Posted by MartinSomerville View Post
    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
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. Delete Block Sub Entities
    By David Bethel in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 22nd Apr 2009, 09:19 pm
  2. tocuhing entities into block
    By ollie in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 28th Jan 2009, 06:06 pm
  3. [VBA] Accessing paperspace block attributes
    By frostrap in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 5th Jun 2008, 11:14 pm
  4. modifying block entities
    By BIGAL in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 28th Jul 2006, 04:09 am
  5. accessing a point which is a block
    By pondy in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 30th Jun 2006, 08:16 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts