Author Topic: Layer Info:  (Read 142 times)

bdeck

  • Hero Member
  • *****
  • Posts: 785
Layer Info:
« on: January 24, 2017, 07:07:01 PM »
Enumerate/select entities on each layer, one layer at a time.

Also, pressing the "d" key gives user a reversible option to delete all items on a layer.

Run macro, and read status bar for instructions. Use Esc key to exit.

The macro selects the entities of each layer to make them stand out, but this version does not yet manage layer visibility. 

Depending on your monitor size and the complexity of the drawing, you may need to modify the macro to fit, pan, or scroll the enumerated types in the output window.

Code: [Select]
'LI.d3m  Layer Info:  enumerates types and selects entities by layer     bdeck  1/2017

dim ecount(130), ename$(130) , layfull(256)
precision 0
nent=sys(9)                     ' define total number of entities in dwg
gosub ntable ' get type names and key names

 >deselect
    {
    }
for laynum = 0 to 255       ' look at each layer
    print "layer ", laynum         
    if laynum=0 or layfull(laynum)=1 then     ' else ignore empty layers
   
        tcount=0           'initialize number of types on this layer
        poscount=0         'initialize number of entities on this layer
        for t=1 to 130
            ecount(t)=0    'initialize number of entities of each type on this layer
        next t
                           
        for i=1 to nent         ' examine each entity to see if it is on this layer
            getattr i,type,sel,lay
            if laynum = lay then
                if ecount(type)=0 then tcount=tcount+1      'tcount=number of types on this layer
        ecount(type)=ecount(type)+1                    'number of entities of each type on this layer
          poscount=poscount +1                              'number of entities on this layer
                putattr i,type,1                                         ' select each entity on this layer
            else
                if laynum = 0  then layfull(lay)=1  'record all populated layers found on first pass
            endif
        next i
       
        if tcount>0 then            ' skip empty layers
            regen                   ' make new selection visible
            gosub showdata

            k= 300
            do  while k>-1
                anykey k
                if k= k_esc then end          '  end with selection intact
                if k=k_d then gosub verify
                if k= k_spc then k=-1
                if k= k_cr then k=-1
            loop
           
    wclose   
             >deselect
            {
            }
         endif
    endif
next laynum

regen
end         

verify:
    sys(1027) =4  'or 1
    message "Do you really want to ERASE all selected items on layer ", laynum, " ?"
    if sys(1028) = 6 or sys(1028) =1  then
        >erase
        {
        }
        nent=sys(9)                   ' redefine number of entities
        k=-1   ' loop exit code
    endif
return
 
showdata:
           wclose
   print "Hit Excape to Exit, Space or Enter to Continue, D to Delete layer"
       
   pc$=poscount
   tc$=tcount
   ln$=laynum

           title$=  "**   "+ pc$+"   ENTITIES   of   "+ tc$ + "   TYPES   on   LAYER   " +ln$+ "   **"
   
    sys$(42)=title$
    sys(132)=0
            sys(133)=0
            window tcount,50
           
            Print "COUNT    TYPE ID     DESCRIPTION"
pcount=4
           
            for t=1 to 130
                if ecount(t)>0 then
                  print "    ", ecount(t), "          ",t,"          ", ename$(t)
                  pcount=pcount+1
                endif
                tlast=t   
                if pcount>45 then maxrows then t=130
            next
return           

ntable:
  ename$(1)="Line"
  ename$(2)="Ellipse"
  ename$(3)="3D Text"
  ename$(4)="Curve"
  ename$(7)="Elliptical Arc"
  ename$(11)="Bezier Curve (4-point)"
  ename$(12)="Bezier Curve (Continuous)"
  ename$(13)="2D Text"
  ename$(15)="Attribute"
  ename$(16)="Circle, Circular Arc"
  ename$(17)="Hatch"
  ename$(22)="Text Arc"
  ename$(24)="Arrow"
  ename$(26)="Symbol"
  ename$(31)="Plane"
  ename$(32)="Grid Header"
  ename$(33)="Grid Line"
  ename$(34)="Group"
  ename$(68)="Construction Line"
  ename$(70)="Point Mark"
  ename$(71)="Attribute Definition"
  ename$(74)="Dimension, Angle"
  ename$(75)="Dimension"
  ename$(76)="Dimension, Diameter/Radius"
  ename$(77)="Dimension, Arc"
  ename$(78)="Dimension, Radius Progressive"
  ename$(79)="Dimension, Progressive"
  ename$(80)="Dimension, Chamfer"
  ename$(81)="Dimension, Coordinate"
  ename$(90)="Bitmap Image"
  ename$(92)="Double Line"
  ename$(93)="Double Curve"
  ename$(94)="Double Bezier"
  ename$(95)="Double Circle/Arc"
  ename$(96)="Double Elliptical Arc"
  ename$(97)="Double Ellipse"
  ename$(119)="Multiline Text"
  ename$(113)="MultiLine"
  ename$(114)="MultiLine Curve"
  ename$(115)="MultiLine Bezier"
  ename$(116)="MultiLine Circle/Arc"
  ename$(117)="MultiLine Ellipse"
  ename$(118)="MultiLine Elliptical Arc"
  ename$(119)="MultiLine Text (2D)"
  ename$(120)="MultiLine Text (3D)"
  ename$(122)="Solid Surface (version 24 +)
  k_d=68
  k_esc=27
  k_spc=32
  k_cr=13
  k_up=38
  k_dn=40
  k_rt=39
  k_lft=37
return

Edit: 1/26/2017 to substitute Putattr for Change command.
Edit: 2/7/2017 to eliminate typo in "for t" loop, reduce size of output window
« Last Edit: February 06, 2017, 09:17:45 PM by bdeck »