Jump to content

Show layer information nested objects


OMEGA-ThundeR

Recommended Posts

Hi,

 

I found a lisp that shows me information of a certain object in an XREF,

The command 'XLIST' doesn't show the information i need so i found something like 'XDUMP.LSP'

 

(defun C:XDUMP (/ obj)
 (while (setq obj (vlax-ename->vla-object (car (nentsel))))
   (vlax-dump-object obj T)
   (vlax-release-object obj)
 )
 (princ)
)

 

This shows me a lot of information and gives me ideas for multiple purposes.

 

However i would like to filter this information, and in this case just to tell me the layer name and it's length.

 

Is there a way to filter out this information. And if yes, how?

 

This is what it shows me when i click on an object (pline):

 

Command: XDUMP

 

Select object: ; IAcadLWPolyline: AutoCAD Lightweight Polyline Interface

; Property values:

; Application (RO) = #

; Area (RO) = 260.425

; Closed = 0

; ConstantWidth = 0.0

; Coordinate = ...Indexed contents not shown...

; Coordinates = (196400.0 442416.0 196390.0 442413.0 196387.0 442412.0 ... )

; Document (RO) = AutoCAD.Application: No document

; Elevation = 0.0

; EntityTransparency = "ByLayer"

; Handle (RO) = "9002"

; HasExtensionDictionary (RO) = 0

; Hyperlinks (RO) = #

; Layer = "NEW-Layer-ASSIST"

; Length (RO) = 50.3466

; Linetype = "ByLayer"

; LinetypeGeneration = -1

; LinetypeScale = 1.0

; Lineweight = -1

; Material = "ByLayer"

; Normal = (0.0 0.0 1.0)

; ObjectID (RO) = 53

; ObjectName (RO) = "AcDbPolyline"

; OwnerID (RO) = 43

; PlotStyleName = "ByLayer"

; Thickness = 0.0

; TrueColor = #

; Visible = -1

; Methods supported:

; AddVertex (2)

; ArrayPolar (3)

; ArrayRectangular (6)

; Copy ()

; Delete ()

; Explode ()

; GetBoundingBox (2)

; GetBulge (1)

; GetExtensionDictionary ()

; GetWidth (3)

; GetXData (3)

; Highlight (1)

; IntersectWith (2)

; Mirror (2)

; Mirror3D (3)

; Move (2)

; Offset (1)

; Rotate (2)

; Rotate3D (3)

; ScaleEntity (2)

; SetBulge (2)

; SetWidth (3)

; SetXData (2)

; Trans

Select object: formBy (1)

; Update ()

; error: bad argument type: lentityp nil

Link to comment
Share on other sites

You are seeing the ActiveX properties & methods for the selected object as returned by the vlax-dump-object function; the output generated by this function cannot be altered.

Link to comment
Share on other sites

Hi,

 

However i would like to filter this information, and in this case just to tell me the layer name and it's length.

 

Try this:

 

(defun c:test (/ nst vl)
 (while (setq nst (car (nentsel "\nSelect object or nested :")))
   (if (vlax-property-available-p (setq vl (vlax-ename->vla-object nst)) 'Length)
     (alert (strcat "Layer    : " (vla-get-layer vl) "\nLength : " (rtos (vla-get-length vl) 2 4)))
     (princ "\nObject doesn't have length property !")
     )
   )
 (princ)
 )(vl-load-com)

Link to comment
Share on other sites

I've been using a modified lisp in order to do two things. Either identify the nested layer or freeze it. Warning, it will freeze the layer for the whole drawing if looking at modelspace through a viewport instead of for just that viewport.

 

;;  LayerQuellPick.lsp [command names: LOP, LOPN, LFP, LFPN]
;;  To "Quell" [turn Off or Freeze] Layers of Picked objects or Picked Nested objects.
;;  If selected object is on current Layer, changes current Layer to first one in Layer table
;;    that is neither off/frozen nor Xref-dependent nor that of selected object, and notifies
;;    User of new current Layer.  [starting current Layer remains shown in Layer Properties
;;    Toolbar pull-down until command is terminated, but if Properties box is up, changes
;;    of current Layer are reflected immediately in its General section, Layer slot.]
;;  If selected nested object is part of a Block/Xref, and on Layer 0 within that reference's
;;    definition, turns off or freezes not Layer 0, but the deepest-nested non-0 Layer on which
;;    that reference or a containing reference is inserted, i.e. where nested object "appears."
;;  [Quirk I haven't found a way around yet: if Layer 0 is off or frozen, things on Defpoints
;;    Layer, even if visible, can't be selected; that Layer can't be quelled while Layer 0 is
;;    (using these commands, though it can be via Layer Manager or Toolbar).]
;;  Kent Cooper, November 2011

;; Modified by Chau Huh, April 2015

(defun C:LOP (); = Layer Off by Picking object(s) [top-level]
   (LQC entsel "" "turn Off" "_off")
); defun - C:LOP

(defun C:LOPN (); = Layer Off by Picking object(s) or Nested object(s)
   (LQC nentsel "/nested object" "turn Off" "_off")
); defun - C:LOPN

(defun C:LFP (); = Layer Freeze by Picking object(s) [top-level]
   (LQC entsel "" "Freeze" "_freeze")
); defun - C:LFP

(defun C:LFPN (); = Layer Freeze by picking object(s) or Nested object(s)
   (LQC nentsel "/nested object" "Freeze" "_freeze")
); defun - C:LFPN

(defun C:LFPNN (); = Layer Freeze by picking object(s) or Nested object(s)
   (LQCC nentsel "/nested object" "Identify" "_freeze")
); defun - C:LFPNN

(defun LQC (func pr1 pr2 opt / *error* cmde ent edata layq nestlist nlayq ldata layc)
 ; = Layer Quell with Current layer changed if necessary
 (defun *error* (errmsg); don't display error message if cancelled with Esc
   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
     (princ (strcat "\nError: " errmsg))
   ); end if
   (setvar 'cmdecho cmde)
 ); defun - *error*
 (setq cmde (getvar 'cmdecho))
 (setvar 'cmdecho 0)
 (while
   (and
     (not ; to return T when (while) loop below is satisfied
       (while
         (and
           (not (setq ent (func (strcat "\nSelect object" pr1 " on Layer to " pr2 ": "))))
           (= (getvar 'errno) 7)
         ); and
         (prompt "\nNothing selected -- try again.")
       ); end while
     ); not
     ent ; something selected
   ); and
   (setq
     edata (entget (car ent))
     layq ; = LAYer to Quell [turn Off or Freeze]
       (if (= (cdr (assoc 8 edata)) "0"); on Layer 0
         (cond ; then
           ((> (length ent) 2); nested entity [other than Attribute] in Block/Xref
             (setq nestlist (last (nentselp (cadr ent)))); stack of references nested in
             (while
               (and
                 nestlist ; still nesting level(s) remaining
                 (= (setq nlayq (cdr (assoc 8 (entget (car nestlist))))) "0"); = Nested [non-0] LAYer to Quell
               ); and
               (setq nestlist (cdr nestlist)); move up a level if present
             ); while
             nlayq
               ; lowest-level non-0 Layer of nested or containing reference(s); 0 if that all the way up
           ); non-Attribute nested entity on Layer 0 condition
           ((= (cdr (assoc 0 edata)) "ATTRIB"); Attribute in Block
             (cdr (assoc 8 (entget (cdr (assoc 330 edata))))); Block's Layer
           ); Attribute on Layer 0 condition
           ("0"); none-of-the-above condition
         ); cond - then
         (cdr (assoc 8 edata)); else - Layer of entity/nested entity
       ); if & layq
   ); setq
   (if (= layq (getvar 'clayer)); selected object is on current Layer - find another
     (progn ; then
       (while ; look for Layer that's on, thawed, non-Xref-dependent, not selected object's
         (and
           (setq ldata (tblnext "layer" (not ldata))); still Layer(s) left in table
             ; nil if it gets to end of table without finding qualifying Layer
           (or
             (=
               (setq layc (cdr (assoc 2 ldata))); = LAYer to [possibly] make Current
               layq ; selected object's Layer
             ); =
             (minusp (cdr (assoc 62 ldata))); off [could be made current, but...]
             (= (logand (cdr (assoc 70 ldata)) 1) 1); frozen [can't be made current]
             (wcmatch layc "*|*"); Xref-dependent [can't be made current]
           ); or
         ); and
       ); while
       (if ldata ; found a qualifying Layer
         (setvar 'clayer layc); then - set it current
         (progn ; else - no qualifying Layer
           (alert "No available Layer to make current\nin place of selected object's Layer.")
           (quit)
         ); progn
       ); if
     ); progn
   ); if
   (command "_.layer" opt layq ""); turn off or freeze Layer of selected object
   (princ (strcat "Turning off layer " layq "\n"))
   (if ldata (prompt (strcat "\nCurrent Layer has been changed to " layc ".")))
 ); while
 (setvar 'cmdecho cmde)
 (princ)
); defun - LQC

(defun LQCC (func pr1 pr2 opt / *error* cmde ent edata layq nestlist nlayq ldata layc)
 ; = Layer Quell with Current layer changed if necessary
 (defun *error* (errmsg); don't display error message if cancelled with Esc
   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
     (princ (strcat "\nError: " errmsg))
   ); end if
   (setvar 'cmdecho cmde)
 ); defun - *error*
 (setq cmde (getvar 'cmdecho))
 (setvar 'cmdecho 0)
 (while
   (and
     (not ; to return T when (while) loop below is satisfied
       (while
         (and
           (not (setq ent (func (strcat "\nSelect object" pr1 " on Layer to " pr2 ": "))))
           (= (getvar 'errno) 7)
         ); and
         (prompt "\nNothing selected -- try again.")
       ); end while
     ); not
     ent ; something selected
   ); and
   (setq
     edata (entget (car ent))
     layq ; = LAYer to Quell [turn Off or Freeze]
       (if (= (cdr (assoc 8 edata)) "0"); on Layer 0
         (cond ; then
           ((> (length ent) 2); nested entity [other than Attribute] in Block/Xref
             (setq nestlist (last (nentselp (cadr ent)))); stack of references nested in
             (while
               (and
                 nestlist ; still nesting level(s) remaining
                 (= (setq nlayq (cdr (assoc 8 (entget (car nestlist))))) "0"); = Nested [non-0] LAYer to Quell
               ); and
               (setq nestlist (cdr nestlist)); move up a level if present
             ); while
             nlayq
               ; lowest-level non-0 Layer of nested or containing reference(s); 0 if that all the way up
           ); non-Attribute nested entity on Layer 0 condition
           ((= (cdr (assoc 0 edata)) "ATTRIB"); Attribute in Block
             (cdr (assoc 8 (entget (cdr (assoc 330 edata))))); Block's Layer
           ); Attribute on Layer 0 condition
           ("0"); none-of-the-above condition
         ); cond - then
         (cdr (assoc 8 edata)); else - Layer of entity/nested entity
       ); if & layq
   ); setq
   (if (= layq (getvar 'clayer)); selected object is on current Layer - find another
     (progn ; then
       (while ; look for Layer that's on, thawed, non-Xref-dependent, not selected object's
         (and
           (setq ldata (tblnext "layer" (not ldata))); still Layer(s) left in table
             ; nil if it gets to end of table without finding qualifying Layer
           (or
             (=
               (setq layc (cdr (assoc 2 ldata))); = LAYer to [possibly] make Current
               layq ; selected object's Layer
             ); =
             (minusp (cdr (assoc 62 ldata))); off [could be made current, but...]
             (= (logand (cdr (assoc 70 ldata)) 1) 1); frozen [can't be made current]
             (wcmatch layc "*|*"); Xref-dependent [can't be made current]
           ); or
         ); and
       ); while
       (if ldata ; found a qualifying Layer
         (setvar 'clayer layc); then - set it current
         (progn ; else - no qualifying Layer
           (alert "No available Layer to make current\nin place of selected object's Layer.")
           (quit)
         ); progn
       ); if
     ); progn
   ); if
   (princ (strcat "Layer: " layq "\n"))
   (if ldata (prompt (strcat "\nCurrent Layer has been changed to " layc ".")))
 ); while
 (setvar 'cmdecho cmde)
 (princ)
); defun - LQCC

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