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.

Drawings lose default layer color and line type

Started by aqua, June 28, 2009, 09:59:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aqua

Designcad 13.13


When I start Designcad 13, the DC_Layer.ini includes colors and line types for the first 2 layers and from layers 100 to 300.

Thus all new drawings have the same default colors and line types.

Sometimes, the DC_Layer.ini loses this data, so that new drawings do not have the correct default colors and line types.

We then restore the DC_Layer.ini from a back-up copy

Does anyone know how to restore a drawing default layer colors / line types from this ini file?

Regards Frank


There are too many to do it manually.

At the moment, we are having to cut and paste from the old drawing into a new.
However, since the drawings are GPS referenced, this is a pain, because the co-ordinates from old to new have to match exactly.

Example data from the DC_Layer.ini is listed below


[Layer Options]
Layer1=1 0 0 0 1 0 1 1.600000000000000e+002 0.000000000000000e+
Layer2=1 255 0 0 1 0 1 1.600000000000000e+002 0.000000000000000e+
Layer100=1 0 0 0 1 0 1 1.600000000000000e+002 0.000000000000000e+
Layer101=1 0 0 0 1 0 1 1.600000000000000e+002 0.000000000000000e+
Layer102=1 255 0 0 1 0 1 1.600000000000000e+002 0.000000000000000e+
Layer103=1 255 0 0 1 0 1 1.600000000000000e+002 0.000000000000000e+
Layer104=1 0 0 0 1 0 1 1.600000000000000e+002 0.000000000000000e+
Layer105=1 0 0 0 1 0 1 1.600000000000000e+002 8.000000000000000e-001
Layer106=1 185 255 0 1 0 1 1.600000000000000e+002 8.000000000000000e-001
Layer107=1 109 109 85 1 2 1 1.600000000000000e+002 8.000000000000000e-001
Layer108=1 0 0 0 1 0 1 1.600000000000000e+002 4.000000000000000e+001
Layer109=1 0 0 0 1 2 1 1.600000000000000e+002 2.400000000000000e+001
Layer110=1 0 0 0 1 0 1 1.600000000000000e+002 8.000000000000000e-001
Layer111=1 0 219 0 1 26 1 1.600000000000000e+002 2.400000000000000e+001
Layer112=1 0 219 0 1 0 1 1.600000000000000e+002 8.000000000000000e-001
Layer113=1 0 0 255 1 0 1 1.600000000000000e+002 8.000000000000000e-001
Layer114=1 0 0 255 1 0 1 1.600000000000000e+002 8.000000000000000e-001




bdeck

#1
In versions 14 + sys vars 530-550 appear to do what you want in bassiccad. Version 15.3 is a safe and economical upgrade choice.

Also, the SetLayerProps command and UpdateLayer command (in versions 14+) allow changing layer properties and updating current entities on that layer to the new properties.

BD


From sdk:

530 - Layer uses specific color (0/1) (V. 14)
(don't set this unless you've already set 531, 532, and 533)

531 - layer red (default 0) (V. 14)

532 - layer green (default 0) (V. 14)

533 - layer blue (default 0) (V. 14)

534 - layer uses specific linestyle (0/1) (V. 14)

535 - linetype (default 0) (V. 14)

536 - linescale (default 2) (V. 14)

537 - unit-based linewidth (default 0) (V. 14)

538 - layer uses fixed linewidth (0/1) (V. 14)
if 0, use the width specified by Sys(537);
if 1, use the linewidth specified by Sys(539)

539 - fixed linewidth in hundredths of mm (ex. 50 = .5 mm). (V. 14)
If the width specified does not match one of the preset values, the actual width will change to the next lowest preset width value (0.00, 0.05mm, 0.09mm, 0.13mm, etc.), so for example 12 would revert to 9, for 0.09mm.

540 - layer uses filled lines (V. 14)

541 - enforce layer color settings on all new entities (V. 14)

542 - enforce layer linestyle settings on all new entities * (V. 14)

550 - Default Fixed Lineweight (in 1/100ths of a millimeter) (V. 14)
[1=visible, 2 = hidden]
This function indicates the current default linewidth if fixed lineweight is active (and no layer settings override the default setting).

DrollTroll

Rather than bothering about the ini file, why don't you save a mostly-empty drawing that has your layers already setup? Then create a macro to load this drawing, and prompt the user for a new "Save As" name so your original doesn't get overwritten. Customize your File menu to include this macro as "New File with Layers", for example.
25 years with DesignCAD

Lar

I remember posting the macro below some time back but I sort'a remember that you couldn't make use of it. I'll post it again just in case.

This macro saves the layer properties of a range of layers in a drawing to another macro. If you run the second macro in another drawing the saved range of layers will be changed to the new props.

You have two layer ranges (0 - 1, then 100 - 300) but you can just specify the layer range to be 0 to 300 (type 0 300 in the macro's input box.

NOTE: There is a bug involved that I reported some years back and I remember DT saying it was fixed but I don't think he grasphed the exact problem and  I don't think the entire situation was fixed. In fact right now I can't remember exactly what it was. I think back then I had to specify that a linestyle as well as lineweight were used even if none were (in the original drawing), in which case the new linestyle whould be that of a zero thickness line. The situation may currently be that I have to specify that there is a linethickness but I don't have to specify that there is a linestyle (if you can figure that out).

'*****MACRO START*****
'Layer Props-Save.d3m
'DesignCAD Macro written by Lar, Nassau, Bahamas
'BasicCAD Macro to save a range of layer props (name, color and linestyle) to a macro file.
'(originally written 15/Dec/2005)

'edit history
'15/Dec/2005, AM: revamped.
'20/Dec/2006: only records layers with names

'This macro will create another macro file that saves layer props for transfer to another drawing...
'To get the props into another drawing files just run the named macro while in the other drawing.
'You will be prompted for a name to save the file under. This name will be prefixed by "LayProps-"

''''''''''''''''''''''''''''''''''''''''
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 (will be prefixed with LayProps-)..." nm$
if sys(999) then end

'IF FILENAME EXISTS...
nufile$ = sys$(24)+"\LayProps-"+nm$+".d3m"
  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$ = """   '-for getting ' in messages, not necessary here.

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

'get range of layers from user...
getrange:
INPUT " Enter Range of Layers to SAVE (eg: for layers zero to ten type: 0 10)..." RR RRR
IF SYS(999) THEN END

'the next line allows user to type a single number if only one layer has to be saved (eg, instead of 10 10, just type 10)...
IF RRR=0 THEN RRR=RR

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

'get current layer for re-instating...
CurLay=sys(3)

print #1, "sys(36)=1   'silent mode on."

print #1, "'get current layer for re-instating..."
print #1, "CurLay=sys(3)"
'print #1, should output a blank line but outputting 1, have to use "" (empty quote)...
print #1, ""

for layy=RR to RRR

'check and hold layer status of layer...
LL=layer(layy)

'if layer is off (=0)...
if ODD(LL\2)=0 then
LayStat=0
goto ExitLayStat
end if

'if layer is un-editable...
if ODD(LL\2)=1 and ODD(LL\4)=0 then
LayStat=2
goto ExitLayStat
end if

'if layer is current...
if ODD(LL\2)=1 and ODD(LL\4)=1 then
if ODD(LL\8)=1 then
LayStat=14
goto ExitLayStat
end if
end if

'if layer is on...
if ODD(LL\2)=1 and ODD(LL\4)=1 then
LayStat=6
goto ExitLayStat
end if

ExitLayStat:

sys(3)=layy   'make layer current to get props.
if sys$(93)="" then goto nex
LayName$=qt$+sys$(93)+qt$   'get layer's name with quotation marks

'before making this layer current...
print #1, "layyy=",layy
print#1, "gosub LatStatSUB"
print #1, ""

'PRINT: MAKE LAY CURRENT, WRITE LAYER'S PROPS...
print #1, "sys(3)=",layy
print #1, "sys$(93)=",LayName$
GetLayerProps layy
print #1, "'LAYER PROPS:"
print #1, "'Layer Colors..."
print #1, "sys(531)=",sys(531)
print #1, "sys(532)=",sys(532)
print #1, "sys(533)=",sys(533)
print #1, "'layer uses specific color.."
print #1, "sys(530)=",sys(530)
print #1, "'Linestyle Settings: linetype, linescale, fixed linewidth..."
print #1, "sys(535)=",sys(535)
print #1, "sys(536)=",sys(536)
print #1, "sys(539)=",sys(539)
'bug with 534  and 538 not behaving, so...
'*******for previous problem (re-use if problem re-occurs):*******************
'print #1, "'layer uses specific linestyle (note 534 not behaving, default to =1)..."
'*************************************************************************
print #1, "'layer uses specific linestyle..."      '*****replace this line with above if problem reoccurs***
print #1, "sys(534)=",sys(534)
'*******for previous problem (re-use if problem re-occurs):*******************
print #1, "'layer uses fixed linewidth (note 538 not behaving, default to =1)..."
'*************************************************************************
'print #1, "'layer uses fixed linewidth..."   '*****replace this line with above if problem reoccurs***
print #1, "sys(538)=1"   ',sys(538)'*******replace 1 when bug (mentioned above) is fixed

print#1, "SetLayerProps ",layy

print #1, ""

'return current layer...
print #1, "'return current layer..."
print#1, "layer(CurLay)=14"
print#1, "layer(",layy,")=LayStat"

print #1, ""
print #1, ""

'return layer stats...
layer(CurLay)=14
layer(layy)=LayStat

nex:
next

'finished...
mes$=qt$+" -done- "+qt$
print #1, "message ",mes$
print#1, "end"

print #1, ""

print#1, "LatStatSUB:"
print #1, ""

print#1, "'check and hold layer status of layer..."
print#1, "LL=layer(layyy)"
print #1, ""

print#1, "'if layer is off (=0)..."
print#1, "if ODD(LL\2)=0 then"
print#1, "LayStat=0"
print#1, "goto ExitLayStat"
print#1, "end if"
print #1, ""

print#1, "'if layer is un-editable..."
print#1, "if ODD(LL\2)=1 and ODD(LL\4)=0 then"
print#1, "LayStat=2"
print#1, "goto ExitLayStat"
print#1, "end if"
print#1, ""

print#1, "'if layer is current..."
print#1, "if ODD(LL\2)=1 and ODD(LL\4)=1 then"
print#1, "if ODD(LL\8)=1 then"
print#1, "LayStat=14"
print#1, "goto ExitLayStat"
print#1, "end if"
print#1, "end if"
print#1, ""

print#1, "'if layer is on..."
print#1, "if ODD(LL\2)=1 and ODD(LL\4)=1 then"
print#1, "LayStat=6"
print#1, "goto ExitLayStat"
print#1, "end if"
print #1, ""

print#1, "ExitLayStat:"
print#1, "return"


'return current layer...
sys(3)=CurLay

'DISPLAY NEW FILE'S PATH AND NAME FOR USER INFO, to confirm location of new file...
message sys$(24)+"\LayProps-"+nm$+".d3m has been created"
end


'LAYER STATUS INFO, see Built-In Functions of BasicCAD Help...
'put this first...
'y=layer(x)
'if ODD(y\2)=0,    -> layer x is invisible.
'if ODD(y\2)=1,    -> layer x is visible.
'if ODD(y\4)=0,    -> layer x is not editable.
'if ODD(y\4)=1,    -> layer x is editable.
'if ODD(y\8)=1,    -> x is the current layer.
'*****MACRO END******

Note: the last macro line will display a 'cool' smiley (with shades) on the forum but that's because the line contains a forward-slash followed by the digit 8. When copying and pasting to notepad the original slash-eight should be pasted and not the smiley.

Lar

aqua

Designcad 13.13

Guys, back again.

I almost have this worked out.
The macro below has 2 issues.

1: It will not close the original drawing.
2: It will not save the new drawing (because it needs the original to be closed as well)

Any clues as to how to fix the code to address these issues?

Regards Frank

DrollTroll - in reference to your suggestion, in the early days, I tried this however it is not as simple and easy as the set-up we have. Every time we start Designcad now, we get a new drawing with all the layer names, colours, and line types automatically. Nothing is required at all by the user. The downside is the mystery of the ini file occasionally losing some of its colors.



'FTM-23/7/2009

'Disable other functions
sys(470)=1

'Silent mode
sys(36)=1

'Make sure no items selected
SYS(80)=0

'Show and unlock all layers (1-400)
for i = 1 to 400
layer(0+i)=6
next i


'Ensure layer 1 is current layer
sys(3)=1

>Regenerate
{
}

>Save
{
  }

'Get drawing name
Fullname$ = SYS$(2)

'Check to see if Working Plane Reset is Required
'Check screen x & Z - If low - then Working Plane Reset may be Required
Screenfmx$ = (sys(600) + sys(601))/2
Screenfmx = Screenfmx$
Screenfmy$ = (sys(602) + sys(603))/2
Screenfmy = Screenfmy$

Screencentrefm = screenfmx * screenfmy
Workplaneyes = 0
If Screencentrefm < (100000000000) then workplaneyes = 1

>SelectLayer
{
<Layer [100]
<Layer [104]
}
If Sys(80) > 0 and Workplaneyes = 1 Then
Message "Your drawing contains an image that may be effected by the working plane rotation reset. You may need to reload the image and align it."
layer(100)=0
layer(104)=0
END IF

'Make sure no items selected
sys(80) = 0

>UnWorkplane
{
  }

>FitToWindow
{
  }

'Identify extremes of drawing
a =0
a=sys(120)
b=0
b=sys(121)
c=0
c=sys(122)
d=0
d=sys(123)

'Select all items in drawing
>SelectAll
{
  }

>SetHandle
{
  <PointXYZ [a, b, 0]
  }

>Copy
{
  }

sys(80)=0


sys(36)=0
'Need to ensure drawing fills screen (This is NOT Fit to Window), otherwise macro freezes after opening new drawing and before copying

'Issue here: It is not closing drawing

>Close
{
  <SaveChanges

  • '  <Filename [Fullname$]
      <Filename ""
    }

    'If a specific filename is given in quotes, the file will be saved with that name.
    'An empty string "" saves the file under its current name.
    'A question mark in quotes "?" will close the file if no changes have been made, or open the "Save Changes?" dialog box if the drawing has changed.

    Message "Existing drawing should have closed"

    sys(36)=1

    'Open new drawing
    >New
    {
    }

    'Paste Original into new
    >Paste
    {
      <PointXYZ [a, b, 0]
      }


    'Make sure no items selected
    Sys(80)=0

    >Fittowindow
    {
    }

    'Rename layers
    Precision 0
    val2$ = 0
    open "i", 1, "c:\Program Files\Aquaflow\Textinfo\Layer names.txt"
    a = 1
    do while NOT eof(1)
    ' Loop through the layers
    Input #1, name$
    Text$ = name$
    ' Make layer a the current layer
    Layer(a) = 14
    ' Name the Layer, (30 chars Max)
    Sys$(93) = Text$
    a = a + 1
    Loop
    Close #1

    >Regenerate
    {
    }

    Message "Click Yes to overwrite existing. Full original drawing path is:", Fullname$

    >SaveAs
    {
       <Filename [Fullname$]
      }

    sys(36)=0

bdeck

#5
Syntax is

>Close
{
<SaveChanges 0                           
}


On a new drawing you can generate a saveas dialog with

>Save
{
}


aqua

#6
Bdeck

Using Designcad 13.13

Tried

>Close
{
<SaveChanges 0                           
}

No luck, still does not close drawing.


And I don't think we can save the new drawing using the same drawing name until we close the original.

Regards Frank

edgar

I'm not sure if this will help or even work--at best it might be a "work around". Instead of closing the old drawing, save it to your Windows "temp" directory; in Vista C:\Temp (a hidden directory) might be protected, C:\ProgramData\Temp is probably usable; I think either will be flushed by the OS on reboot (I'm not sure for XP where the Temp folder is located). You may now save the new file with the old name.
-Ed

bdeck

#8
Hi Frank,

The following test macro works in version 17.2 and 15.3


sys213=sys(213)
>New
{                       
}
sys(213)=sys213

>Close
{
<SaveChanges 0                           
}
Message "done"
end

Apparently DC doesn't like running macros without an open drawing. So you have to create a New drawing before closing the old one. Sys213 sets the drawing index to the old drawing before closing.

Putting "New" immediately after "Close" (as suggested by the docs for the Close function) did not work for me.

BD

aqua

Designcad 13.13

Note: Still using 13.13, so some of the code and solutions that later versions can use can't be used.

Couldn't get the Close code to work, so simply split the macro into 2 seperate macros.

Regards Frank