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.

LAYER PRINTING

Started by roger_c130, February 01, 2012, 05:37:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

roger_c130

I have a very large drawing with almost 100 layers.  I would like to print a list of all active layers so I can tack it to the wall for quicker reference.  Some of us just seem unable to get away from paper.

edgar

Quote from: roger_c130 on February 01, 2012, 05:37:00 AM
I would like to print a list of all active layers so I can tack it to the wall for quicker reference.
+1
This might be possible via macro but I do not see how with the current abilities.
-Ed

Lar

#2
Here's my macro for doing just that. This is specifically for pasting into a spreadsheet or database so commas are added between layer number and name. Dcad will create spaces around the commas so use the replace command to change space -comma-space to comma  (" , " to ",").

If you open the file before the macro is completed the text won't be visible. So if your computer is slow and you are saving a big range of layers you may be wondering if the macro is done yet. The macro ends with 2 messages: once all the layer names are written a message will display the file name. When you click ok another message will be displayed reminding about "spaces around the commas". Once you click ok the macro will be completed.

Instructions when asked for layer range:
For a range such as 0 to 100 enter: 0 100
If you want all layers just click 'ok' without entering anything (you can still enter numbers)...
If you want just one layer just enter one number (eg: for just layer 1 enter: 1)

If your version of dcad has less than 2000 layers then change the 2000 in the following lines to how many layers your dcad has...

IF RR=-9 then
RR=0
RRR=2000
end if


You have to give a filename to be saved under. The sys$(24) in the code below puts the file in the default macro folder. If you want it to go elsewhere change the code appropriately:
nufile$ = sys$(24)+"\LayTxt-"+nm$+".txt"

Lar


'Layer names for text file, with commas.d3m
'Adapted from 'Layer Props-Save.d3m'
'DesignCAD Macro written by Lar, Nassau, Bahamas
'BasicCAD Macro to save a range of layer name to a text file with commas for use in a spreadsheet or database.
'(originally written 15/Dec/2005)
'(adapted 17 August 06)

'edit history:
'6 July 06
'Added options for empty layers with no names and replace info at top of file.


'This macro will create a text file that saves the layer's "name,number" for ultimate use in a spreadshet or database...
'You will be prompted for a name to save the file under. This name will be prefixed by "LayTxt-", extension "txt"
'To get the names into a ss or db Copy the text and Paste into the ss or db.
'The commas will separate the info into different cells.
'Dcad will place spaces around the comma so get rid of them in the new file (Replace: space-comma-space with comma)...

''''''''''''''''''''''''''''''''''''''''

precision 0      'so that layer numbers in the new file has no decimal point and trailing zeros

sys(36)=1   'silent mode on.

'NAME FILE...
fname:
input "Enter name for new file, no extension (will be prefixed with LayTxt-) <or Cancel to end>..." nm$
if sys(999) then end

nufile$ = sys$(24)+"\LayTxt-"+nm$+".txt"

'IF FILENAME EXISTS...
 if  exist(nufile$)=1 then
  input "File name exists. 1=overwrite; 2=rename; 3=cancel" exis
   if exis=3 then end
   if exis <>1 then goto fname
end if

'IF FILENAME IS INVALID...
  if  exist(nufile$)=-1 then
   input "Name is invalid. 1=rename; 0=cancel" inv
    if inv=1 then goto fname
    if inv=0 then end
end if

qt$ = """   'not necessary in this macro...

'CREATE NEW FILE...
open "o", 1, sys$(24)+"\LayTxt-"+nm$+".txt"

'spaces will be placed around comma so get rid of them in the new file (Replace: space-comma-space with comma)...
print #1, "NOTE: PLEASE Replace:  space-comma-space { , } with comma {,})..."
print #1, "You should also replace: comma (,) with dash (-) in case..."
print #1, "...then replace replace underscore (_) with comma to create further catagories in database file."
print #1, ""

'get range of layers from user...
getrange:

RR=-9
INPUT " Enter Range to SAVE (default=All Layers {ie: just click ok})..." RR RRR
IF SYS(999) THEN END

IF RR=-9 then
RR=0
RRR=2000
end if

'if only one layer just enter it in once...
IF RRR=0 THEN RRR=RR

IF RRR<RR THEN
MESSAGE "Range is negative! Please re-enter range..."
goto getrange
end if

sys(1027)=3  ' message box style = Yes/No/Cancel
message "Include empty layers without names?..."

if sys(1028)=2 then end   '6=Yes; 7=No [1=OK; 2=Cancel] [3=Abort; 4=Retry; 5=Ignore]
if sys(1028)=7 then nonamee=1


for layy=RR to RRR

sys(3)=layy   'make layer current to get props.
LayName$=sys$(93)   'get layer's name, no quotation marks necessary...


'if noname, no layer name and no entities in layer [y = 0, 2, 6, or 14] then skip...
if nonamee=1 and LayName$="" and ODD(layer(layy))=0 then goto nex


'PRINT: MAKE LAY CURRENT, WRITE LAYER'S: "name comma number".. ..
print #1, layy,",",LayName$

nex:
next

'finished...
'DISPLAY NEW FILE'S PATH AND NAME FOR USER INFO, to confirm location of new file...
sys(1027)=0  ' message box style = OK
message sys$(24)+"\LayTxt-"+nm$+".txt has been created"
message "NOTE: Dcad will place ~spaces~ around the commas in the new file so get rid of them.", chr$(13), "(Replace: ~space-comma-space~ with ~comma~)..."

end



Bob P

sys$(24)?  I don't have that on my latest list. (V17...).  Does anyone have an addendum to the sys() and sys$() functions?  I couldn't find sys$() updates in the BasicCad section.

Lar

#4
Here is what I have Bob. I put it in the code box so no funny smileys show up.

Hey, funny thing is 24 isn't there (originally) and 23 is listed as the macros folder. That's weird. I must have gotten it from the old macros.hlp file.

I ran a test with the following macro and both returned the same thing.

message sys$(24)
message sys$(23)

I'll paste it in anyway. The other funny thing is that wherever you open a macro from becomes the default macro folder (for that session).

Hey Bob, let me know if this is the same file you have, minus the note on 24 that I just plucked in.

Lar


The SYS$ function represents several different DesignCAD system variables in string format. SYS$(6), for example, is the current path name. A list of the available SYS$ functions follows:

0 – Commandline parameters. (V. 14)
This function contains any extra information that was on the command line after the macro name, or was passed by the CMDLINE statement to a RUN or CALL statement. For example, if you run mymacro.d3m by typing "mymacro.d3m 1, 10, 100" at the commandline, when the macro checks Sys$(0) it will find the string "1, 10, 100"
1 - Entity text string. This is the text from a Text or Attribute entity that was "loaded" with the ENTITY statement (read_only)

2 - Current drawing name (with full path) (read_only).
Contains an empty string until the drawing has been saved at least once.
3 - Current drawing name (minus path) (read_only).
Contains an empty string until the drawing has been saved at least once.

5 - Current drive (read_only)
6 - Current path name
7 - Current time (read_only)
8 - Current date (read_only)

20 - Default drawing directory
Terminate the desired directory with a backslash '\'.  Example:
Sys(20) = "C:\Program Files\IMSI\DesignCAD 3D Max 14\My Drawings\"

21 - Default symbol directory
Terminate the desired directory with a backslash '\'. Example:
Sys(21) = "C:\Program Files\IMSI\DesignCAD 3D Max 14\Symbols\2D Symbols\Windows\"

22 - Default bitmap directory
Terminate the desired directory with a backslash '\'.
23 (and 24, it seems) - Default macro directory
Terminate the desired directory with a backslash '\'. Example:
Sys(23) = "C:\Program Files\Addons\DrollTroll's Macro Tools\"
25 - Default view directory
Terminate the desired directory with a backslash '\'.
34 - Default Material List directory
Terminate the desired directory with a backslash '\'.
36 - DesignCAD root directory (read_only)

37 - Default import directory
38 - Default export directory
39 - Default EXE directory

40 - Windows clipboard text

41 - Input window caption. Use an empty string "" for no title bar.
42 - Output window caption. Use an empty string "" for no title bar.

43 – Default Symbol Library Path (V. 15)

90 - Name of current view window
91 - Name of current material

92 - Entity color. This 9-digit string represents the RGB values for the color of the item referenced by the last ENTITY statement. It replaces Sys(92) in earlier versions of DesignCAD. The first three characters represent the red component, the second three represent the green component, and the last three the blue component of the color. (read_only). Note: This function is no longer necessary, as there are dedicated Sys() functions, Sys(290) – Sys(292), which directly represent the RGB values of the current Entity color.

93 - Name of current layer (30 characters, max.)
94 - Name of current TrueType font
95 - Name of current Vector Font

100 - Registered serial number (read_only)
101 - Registered user name (read_only)
102 - Registered company name (read_only)
103 - DesignCAD release date (read_only)

104 - DesignCAD release time (read_only)
105 - DesignCAD version number (read_only)
200 - Statusbar panels visibility (write_only) (V. 13)
This is a six-digit string consisting of ones and zeros. Each digit controls the visibility of one of the panes of the status bar, as follows:
Digit Panel
1 Snap mode
2 Points counter
3 Zoom factor
4 Drafting mode
5 Preset Point mode
6 Working Plane
The command prompt panel cannot be turned off. The string must be exactly six characters in length, or it will be ignored. Any character other than "0" (zero) will make the corresponding panel visible.
Examples:
Sys$(200) = "010001" ' shows only points counter and working plane
Sys$(200) = "111111" ' turns all panels back on

Notes: The string must be exactly six characters long, or it will have no effect on the current settings. Any character other than "0" will turn the corresponding panel ON.

296 - Entity Symbol Name. (Read-only) (V. 13)
This function contains the full path and filename of the symbol entity currently selected by the ENTITY statement, or the block name if the entity is a block.
297 - Entity Attribute Definition Tag. (V. 13)
This function contains the tag name of the Attribute Definition currently selected by the ENTITY statement.
298 - Entity Attribute Definition Prompt. (V. 13)
This function contains the user prompt for the Attribute Definition currently selected by the ENTITY statement.

299 - Entity Attribute Definition Default Text. (V. 13)
This function contains the default text of the Attribute Definition currently selected by the ENTITY statement.
300 - Entity Name. (V. 16)
This function contains the name of the ENTITY statement.
301 – Layer Group Name. (V. 17)
This function contains the name of the current layer group.
390 - Indexed Block Attribute Definition Tag. (V. 13)
This function contains the tag name of the indexed Attribute Definition that is contained in a Block entity currently selected by the ENTITY statement. The index of the attribute definition being described is set by Sys(391).

391 - Indexed Block Attribute Definition Default Text. (Read-only) (V. 13)
This function contains the default text string for the indexed Attribute Definition that is contained in a Block entity currently selected by the ENTITY statement. The index of the attribute definition being described is set by Sys(391).
392 - Indexed Block Attribute Definition Text. (V. 13)
This function contains the actual text contents of the indexed Attribute Definition that is contained in a Block entity currently selected by the ENTITY statement. The index of the attribute definition being described is set by Sys(391).

Sample code -- how to extract Attribute Definition data from blocks:

For entnum = 1 To Sys(9) ' check every entity in the file
 Entity entnum

 On Error Resume
 If (Sys(90) = 26) And (Sys(296) = 3) Then
 ' This is a Symbol entity, of subtype Block
   blkName$ = Sys$(296)
   nAttributes = Sys(390)
   for i = 1 to nAttributes  
   ' get data for every attribute definition in this
   ' block instance
     Sys(391) = i
     isFixed = Sys(392)
     isVisible = Sys(393)
     tag$ = Sys$(390) ' attribute definition tag
     defText$ = Sys$(391) ' default text string
     attText$ = Sys$(392) ' actual text string
   next i
 End If
 If Sys(90) = 71 Then
   ' This is an attribute definition (outside a block)
   isFixed = Sys(298)
   isVisible = Sys(299)
   tag$ = Sys$(297) ' attribute definition tag
   prompt$ = Sys$(298) ' user prompt
   defText$ = Sys$(299) ' default text string
 End If

 If Sys(90) = 68 Then
   ' This is a construction line
   CLineType = Sys(297)
   If CLineType = 0 Then
       CLMsg$ = "Invalid Data"
   End If
   If CLineType = 1 Then
       CLMsg$ = "Construction Line"
   End If
   If CLineType = 2 Then
       CLMsg$ = "Construction Ray"
   End If
 End If

Next entnum

803 - Current Paperspace Layout Name

To use the SYS$ function in a macro, use it like you would any other string function. For example, the following macro displays the current drive and path name:

message Sys$(6)

Bob P

That's what I have too.  Notice the lack of sys$(24), which is part of the file-name string in the macro.

roger_c130

Thanks for your response.  Never having used macros is going to offer a big challenge.  It will have to wait though until I move.

Lar

#7
It's not that big of a deal, roger. Just copy and paste the code to Notepad and save to a sensible name with a d3m extension (Print layer Names.d3m, for example. If you like to use the command line {accessed by pressing the space bar} name it something short with no spaces). I suggest you create a folder called something like 'Macros' to save this and your future macros in. Then, in dcad press % or go to Tools menu> Macro Execute, double click the macro filename and follow the prompts.

I see where I should update the macro so the user can click a 'yes' or 'no' button instead of entering numbers for negative or positive.

Lar