DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

How do you print a list of the layer names?

Started by magic, October 06, 2014, 11:30:18 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

magic

Hi all,

One of my customers asks, if it is possible to print a list of the layer names. And how?

Thank you very much.
It's a kind of magic!




Bob P

sys$(93) is the name of the current layer.  You'd have to cycle through all the layers  to compile the list.

REF

Or you could look and copy from your DC_Layer.ini file in you Dcad folder.
DesignCAD user since 1990

impulse

I have attached a macro that was part of a Save and/or Load Layer names utility. You can save the layer names of a drawing an then load them into another drawing to make the layer naming structure identical. 
This was written years ago (as in file date 2003).  It worked fine then, but I have not used it much in the last decade or so.
I noticed that it's first line of output is based on a sys$(2) call, which is supposed to print the filename at the top of the layer list but, it seems to print something odd. Several of my legacy macros are having file directory problems, probably related to the SYS$ calls

When running it, you get a choice of writing the names  to a text file  or  listing the names of the Layer Name text file from the previous time the macro was run.

It only does the first 100 layers, but that is an easy fix.
The file saved goes to the macro directory and is coded to be "LayNames.TXT "

It uses a command line call to NOTEPAD.exe, so you can do a file save as from there to put the list somewhere else. I have no idea what issues one might have when running this on a Current OS, Current DCAD installation...I'm running XP

-jimpulse

     

magic

Hi impulse,

Thank you very much for that.

It works fine on v. 24 and Windows 7 Ultimate.
It's a kind of magic!




prl

#5
Similar to what Jim posted.

''Program: llist.d3m (layer list with on off used and empty status)

'10/7/2014

dim layr$(2000), state$(2000), onoff$(2000), layname$(2000)
sys(36)=2 'silent mode

quote$ = """

Precision 0
outfile$="c:\dcadlayers.txt"
open "o", 1, Outfile$

total=2000 'you can change this to the number of layers you want to cycle through
count=0
currentlay=sys(3) 'store current layer

now$ = currentlay

for i = 0 to total
  sys(3) = i
  Nameflag=0
  y = LAYER(i)
 
  if sys$(93)<>"" then Nameflag =1
 
  if Nameflag=1 or ODD(y)=1 then
    count = count+1
    layr$(count)=i
    layname$(count)=sys$(93)
    if ODD(y\2)=1 then
       onoff$(count)=" ON " 'layer x is visible
    else
       onoff$(count)=" OFF" 'layer x is invisible
    end if
    if ODD(y)=1 then
       state$(count)=" USED    "
    else
       state$(count)=" EMPTY   "
    end if
  end if
next i

for i =  1 to count
   if len(layr$(i))=1 then layr$(i)="00"+layr$(i)
   if len(layr$(i))=2 then layr$(i)="0"+layr$(i)
   layr$(i) = layr$(i)+" "
   thestring$ =  layr$(i)+onoff$(i)+state$(i)+layname$(i)
   print #1, thestring$
next i
close #1

sys(3)=currentlay 'restore current layer
sys(4)=0


NotePad$ = "NOTEPAD.EXE "+outfile$
RUN NotePad$,1

End



Erron1

Hello everyone,

I've tried your all macros!
Unfortunately, this functioned only partially!
I have Windows 8.1 (64 bit)!
"Notepad" I had error messages, the text file I have spend hours looking on the PC (notebook).
Since I have installed 8 active versions of DesignCAD 3D MAX, I wanted to reconfigure because not all (paths)!
And I wanted to use the same name as shown in the drawing, so that you can have "simultaneously" analyzed several drawings.
So that you also can analyze multiple versions, I have appended ".txt" to the complete name.
The text files "MyDraw.dc.txt" and "MyDraw.dcd.txt" are then added to the drawings of "MyDraw.dc" and "MyDraw.dcd".
For other extensions then according to this example.


' Listlayers.d3m
'
' Program lists the coated layer and writes the data to a file
' with the same name as the drawing name + ".txt"

' Programm listet die belegten Layer auf und schreibt die Daten in eine Datei
' mit demselben Namen wie der Zeichnungsname + ".txt"
'
' Macro by Reinhard Steuer (Erron1), Germany, October 2014
'
MaxLayers=2000
Pre=PRECISION
PRECISION 0
' Display Sprache Deutsch/Englisch | Display Language German/English
D$=Err$(301)
if D$="Setze Punkte: 1,2,3-Schnittfläche, (4-Seite, die entfernt wird)" then
   talk=1
else
   talk=0   ' default
end if
FileName1$=sys$(2)
if FileName1$="" then
   sys(1027)=0   '[0=OK (default), 1 = OK/Cancel, 2 = Abort/Retry/Ignore, 3 = Yes/No/Cancel, 4 = Yes/No, 5 = Retry/Cancel]
   if talk=1 then
      Message "Die Zeichnung wurde noch nicht gespeichert! Bitte erst Speichern!"   
   else
      Message "The drawing has not yet been saved! Please save!"   
   end if
   STOP
end if
' Damit kann man MyDraw.dc und MyDraw.dcd .... voneinander unterscheiden!
' So that you can distinguish... MyDraw.dc and MyDraw.dcd!
outfile$=FileName1$ + ".txt"

open "o", 1, Outfile$
CurrentLayer=sys(3)  'save the current level

sys(36)=1   'silent mode optional
on error goto end1  'for versions that have less than 2000 layers (below v19)
for activlayer=0 to MaxLayers
   activlayer1$=activlayer
   activlayer1$=right$("    " + activlayer1$,4)
   LayerStatus$=""
   sys(3)=activlayer
   y=layer(activlayer)   '
   if ODD(y)=1 then  ' -> entities are in layer. [y = 1, 3, 7, or 15]
      if ODD(y\2)=0 then   ' -> layer x is invisible. [y = 0 or 1]
         LayerStatus$=LayerStatus$ + ", invisible"
      else   ' -> layer x is visible. [y = 2, 3, 6, 7, 14, or 15]
         LayerStatus$=LayerStatus$ + ",   visible"
      end if
      if ODD(y\4)=0 then   ' -> layer x is not editable. [y = 0, 1, 2, or 3]
         LayerStatus$=LayerStatus$ + ", not editable"
      else   ' -> layer x is editable. [y = 6, 7, 14, or 15]
         LayerStatus$=LayerStatus$ + ",     editable"
      end if
      if activlayer=CurrentLayer then   
         LayerStatus$=LayerStatus$ + ",   activ"
      else
         LayerStatus$=LayerStatus$ + ", inactiv"
      end if
      name1$=sys$(93)
      if name1$="" then
         name1$=", no layer name"
      else
         name1$=", " + name1$
      end if
      LayerStatus$=LayerStatus$ + name1$
      print activlayer1$, LayerStatus$
'      Message activlayer1$, LayerStatus$   ' optional
      print #1, activlayer1$, LayerStatus$
   else   ' -> no entities in layer x. [y = 0, 2, 6, or 14]
   end if
next 'activlayer

end1:
close 1
end2:
sys(3)=CurrentLayer     'restore original current layer...
PRECISION Pre
NotePad$ = "NOTEPAD.EXE "+outfile$
RUN NotePad$,1

END


I hope the macro works with you too!

With friendly wishes
Reinhard/Erron1

Sorry, because my English is very bad!
i7, WIN 8.1 Pro x64, 32 GB RAM

active versions
German language:
DesignCAD 3D Max 20, 21, 22, 23, 24

English language:
DesignCAD 3D Max 20, 21, 22, 23, 24.1, 25