Unlock All

Started by prl, January 13, 2013, 07:25:29 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

prl

The attached file will make editable (unlock) layers without regenerating the screen.  Similar to using the Layer Options dialog and clicking on the Unlock All button.  You can hotkey or add this executable to a toolbar.  As far as I can tell, it works for version 15 to 22.


paulerens


prl

#2
Quote from: paulerens on January 13, 2013, 02:58:09 PM
prl,
This is the answer!

Paul,  the file is an executable.  If you are going to launch the executable from a DesignCAD macro, the macro will need to look like this.  For BasicCAD to find the file, it will need to be placed in the executable folder you have set for DesignCAD.  Attached is a jpg.


'Program: ua.d3m (unlock all)

run "unlockall.exe"

End



One can run the executable from:

Windows (double click the program while DesignCAD is running).
Assigned to a Dc Hotkey
Assigned to a Dc Toolbar
From Dc command line
From a macro (see above)

dcadRob

Why did you do it as an exe?

prl

Can't push that button in the Layer's Option Dialog any other way and can't get to the layer states with BasicCAD.

dcadRob

Isn't this the same as the code you posted in the other thread where you unlock but don't update the screen?

prl

#6
Quote from: dcadRob on January 14, 2013, 05:21:43 AM
Isn't this the same as the code you posted in the other thread where you unlock but don't update the screen?

No.  The fsel.d3m and the UnlockAll.exe have different behaviors.

1. The fsel.d3m will let a user select one (layer locked) group or solid.  It then immediately restores the locked layer status of all other items.

2.  The unlockall.exe is equivalent to opening the layers option dialog and clicking the "unlock all" button.  All items even on invisible layers are now unlocked and will stay that way until you do something with DesignCAD where it then fixes itself by going back to the default state of automatically locking invisible layers.

And to be clear, I use the words Locked and Unlocked to be synonyms for "Not editable" and "Editable".  They are one and the same term for me.



Dr PR

prl,

Very clever!

I agree that most users and the documentation treat locked/unlocked and uneditable/editable as synonyms. This is primarily because the lock icon actually displays the editable state most of the time (it doesn't correctly display the editable state of an invisible and unlocked layer).

****

However, in the operation of the program these things are not synonymous, and it is a mistake to assume they are. This is what has caused a lot of confusion in this discussion. As I have demonstrated many times, the program has two distinct variables, A and B. Call them whatever you want, but one controls the visibility of a layer and the other controls whether or not you can change the contents of a layer.

"Editability" is a misnomer that is promulgated by the User Reference and the help files. It IS NOT controlled by a single variable. It is determined by the logic state of "A AND B." To be "editable" the visibility variable must be ON and the "change" variable must be ON. So the "change" variable IS NOT an editability variable - both variables are part of the "editability" equation.

However, you can change the contents of any layer if the "change" variable is ON ("Unlock All" sets all "change" variables to ON). In other words, you can edit layers that are not "editable." Clearly, the term "editable" is a very poor choice for this logic state.

"Editability" is imposed upon us by the program code. The "visible" and "change" variables are just values stored in memory. If you do not make the distinction between the logic state and the variable state you will be confused as to how the program works. You can edit "uneditable layers!" That is certain to cause confusion.

Personally, I prefer the term "locked" to mean the "change" variable is OFF, and "unlocked" to mean the "change" variable is ON. Unlocked layers can be edited, even though they are uneditable. That is screwy!

This is why I always think of the variable states - there is nothing unmbiguous about how they work.

Phil
DesignCAD user since 1987

prl

Phil, actually I don't follow what you just wrote.  Go to this topic and help fill in what is missing.  Maybe I'll see what you are talking about.

http://forum.designcad.com/index.php?topic=4760.msg29990#msg29990

Dr PR

prl,

Note: this is a duplicate of my response on the other thread.

To quote Lar:

'y=layer(lay)
'if ODD(y)=0,         'no entities in layer lay
'if ODD(y)=1          'entities are in layer lay
'if ODD(y\2)=0        'layer lay is invisible.
'if ODD(y\2)=1        'layer lay is visible.
'if ODD(y\4)=0        'layer lay is not editable.
'if ODD(y\4)=1        'layer lay is editable.
'if ODD(y\8)=1        'lay is the current layer.


'0 – Invisible and not editable
'2 – Visible but not editable
'6 – Visible and editable
'14 – Set as current layer


Sorry about the idiotic happy face. The forum did that, not me.

The control variable is a 4 bit nibble (the lower 4 bits of a byte), with each bit defined this way:

Bit 0 = layer empty state, 0 = the layer is empty, 1= the layer is not empty
Bit 1 = layer visibility state, 0 = invisible, 1 = visible
Bit 2 = layer locked state, 0 = locked, 1 = unlocked
Bit 3 = current layer, 0 = not current layer, 1 = current layer

Note: bit 2 DOES NOT control the "editability" of  alayer as defined in the User Reference and help files - see below.

Now do the binary to decimal conversions:

Bibary    Decimal     Functions
0000 =       0      =  not current, locked, invisible, empty
0001 =       1      =  not current, locked, invisible, not empty
0010 =       2      =  not current, locked, visible, empty
0011 =       3      =  not current, locked, visible, not empty
0100 =       4      =  not current, unlocked, invisible, empty
0101 =       5      =  not current, unlocked, invisible, not empty
0110 =       6      =  not current, unlocked, visible, empty
0111 =       7      =  not current, unlocked, visible, not empty
1000 =       8      =  current, locked, invisible, empty
1001 =       9      =  current, locked, invisible, not empty
1010 =      10     =  current, locked, visible, empty
1011 =      11     =  current, locked, visible, not empty
1100 =      12     =  current, unlocked, invisible, empty
1101 =      13     =  current, unlocked, invisible, not empty
1110 =      14     =  current, unlocked, visible, empty
1111 =      15     =  current, unlocked, visible, not empty

If you do the math that lar has posted to test each bit independently,

if dividing by 1 does not return an odd value, bit 0 = 0  = the layer is empty
if dividing by 1 returns an odd value, bit 0 = 1               = the layer is not empty
if dividing by 2 does not return an odd value, bit 1 = 0  = the layer is invisible
if dividing by 2 returns an odd value, bit 1 = 1               = the layer is visible
if dividing by 4 does not return an odd value, bit 2 = 0  = the layer is not editable (locked)
if dividing by 4 returns an odd value, bit 2 = 1               = the layer is editable (unlocked)
if dividing by 8 does not return an odd value. bit 3 = 0  = the layer is not the current layer
if dividing by 8 returns an odd value. bit 3 = 1               = the layer is the current layer

As you can see, bit 1 controls the visibility of a layer, and bit 2 controls whether or not the contents of the layer can be changed. These are the two variable I have been talking about in other threads.

The "editability" control that the program code enforces is the logical and of bits 1 and 2, so the editability state is determined by examining these two bits (where x means don't care):

x00x = locked, invisible     = uneditable
x01x = locked, visible        = uneditable
x10x = unlocked, invisible = uneditable
x11x = unlocked, visible    = editable

To determine if a layer is "editable" as defined in the program code you must do this:

IF dividing by 2 returns an odd value, bit 1 = 1 = the layer is visible

AND

IF dividing by 4 returns an odd value, bit 2 = 1  = the layer is unlocked

THEN the layer is "editable" (visible and unlocked).

However, any time bit 2 = 1 (unlocked) you can edit the contents of the layer, even if bit 1 = 0 (the layer is not visible)!

For this reason, you can edit the contents of an "uneditable" layer. The term "editability" is a misnomer. However, you cannot edit the contents of a locked layer (bit 2 = 0) even if the layer is visible.

Does this answer your questions?

Phil
DesignCAD user since 1987

prl

Seriously Phil, this is neat and I'm glad you got it, but in terms of being useful, it isn't.

Add something useful to the table that I can work with. 

Dr PR

prl,

Sorry, but I guess you must define what you mean by "useful."

How can understanding how the program works not be useful?

Phil
DesignCAD user since 1987

prl

Quote from: Dr PR on January 14, 2013, 02:29:54 PM
Sorry, but I guess you must define what you mean by "useful."

Go to this http://forum.designcad.com/index.php?topic=4760.msg29990#msg29990 and tell me what layer state combination is missing.  I'll gladly add it.

Dr PR

prl,

You left out states 8 through 13, all on the currently active layer. I presume you want your code to work with objects on the currently active layer?

Also, I assume you can define variables with names to equate to bit 0, bit 1, bit 2 and bit 3, and this makes it unnecessary to remember the bit order. However, for the math to work you must be conscious of the bit order. That is why I referenced the bits in order of ascending precedence in my text descriptions (bit 0 - empty -  is least significant bit, and bit 3 - current layer - is most significant). It isn't necessary, but listing them backwards increases the probability that someone could get confused.

Also, this issue of "editability" should be understood. It is not controlled by bit 2 alone, whereas the real control of whether or not you can edit objects on a layer is controlled solely by bit 2. Forget this and you risk errors.

Phil
DesignCAD user since 1987

prl

#14