News:

Please note new Forum URL: forum.designcad.com

Main Menu
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.

Locking layers

Started by Pearlitic, January 03, 2017, 08:01:38 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Pearlitic

I know that Layer (7) = 14, e.g. layer 7 is the active layer
I also get that sys(3) = 7 is the same thing.

I find that my macro works well if the other layer is locked.  Sometimes my program will apparently select a point in an inactive non locked area.

What is the correct statement if I want to lock all layers except layer 7 (controlled by a variable) in my program?

I am in the final stretch with my program.  I can intersect the solids on the screen and it works.  I have the 2D selection mode shut off as my point selection is in 3D.

I am using a statement "sys(26) = 1" .

I am also using the statements "sys(80) = 0" and sys(81) = 0.

I can manually intersect but I don't want to do it.  I suspect that my program is selecting a point in another layer.

Thank you.


Pearlitic

Lar

#1
This is how I do it (except it turns the other layers off as opposed to only locking them):

for l=0 to 2000     'change this according to how many layers your version has...
if l=sys(3) then goto nexx   'this skips the current layer but may not be necessary for later versions. I used when a macro was abled to turn off the current layer and keep now for safety...
layer(l)=0
nexx:
next

regen   'without this it would appear no layers were turned off (works for active window only). I leave this out if I want to see the other layers even though they are off...

'message "Status of current layer (",sys(3),") = ",layer(sys(3))   '**THIS IS OPTIONAL, FOR DEBUGGING**. It will tell you what the status of the current layer is if you remove the safety line above (remove the apostrophe to use)... 


Lar
PS: to regenerage all the windows use:
>RegenerateAll
{
}


Lar

Bob P

Here's something similar, except it allows more than one layer to be displayed. Note that it only deals with the first 1000 layers, (but that can be changed).
' Program ssl.d3m 
' Show Selected Layers"
' If no entities are selected, all layers (up to 1000) but the current one are hidden
' If entities are already selected, the layer of the first is made
' current and the rest are left visible
' Bob Putnam  1/28/13
'
start:
'check version number
x$=sys$(105)
ver$=left$(x$,2)
ver=val(ver$)
if ver>20 then
maxlay=1000
else
maxlay=10000
end if
dim entlist(maxlay)
dest=sys(3)  'Current layer

if sys(80)=0 then goto nopts 'Number of entities currently selected

points:
dim laystat(10000)  'Create a space to store layer status's of entities
for n=1 to 10000  'Set the default of each to zero
laystat(n)=0
next n

nsel = sys(80)  'Number of entities currently selected
for j = 1 to nsel
getselect j, entlist(j)  'Get the entity number of each entity into an array
next j
sys(80)=0  'Unselect all

getattr entlist(1), type, select, laynum  'Get the attributes of the first entity into an array
layer(laynum)=14  'For the first selection, set the layer status to 14 (Current)

if nsel<2 then goto onlyone

for j = 2 to nsel  'Cycle through the rest of the entities
getattr entlist(j), type, select, laynum  'Get attribute of the other entities
laystat(laynum)=1  'For a visible number, set the status to 1
next j

onlyone:

for j=1 to 2000
if laystat(j)=0 then
layer(j)=0
else
end if
if laystat(j)=1 then
layer(j)=6
else
end if
if laystat(j)=2 then
layer(j)=14
else
end if
next j

>RegenerateAll
{
}

goto end

nopts:
for j=1 to 2000
if j=sys(3) then j=j+1
layer(j)=0
next j
'sys(3)=dest

>RegenerateAll
{
}

END:

Pearlitic

Lar, used
'layer(l)=0 and the loop as suggested.  This appears to do what I want to do.  Shut off all layers except the current layer.  Great.

Thank you very much.

Pearlitic

How do I completely delete a layer in macro?

I am still having problems with Solid Intersect.

Thanks,

Gary

Bob P

#5
Quote from: Pearlitic on January 17, 2017, 07:57:36 PM
How do I completely delete a layer in macro?

I am still having problems with Solid Intersect.

Thanks,

Gary
Once you've locked all the layers except the one you want to erase:

>SelectAll
{
  }

>SelectDelete
{
  }

*By the way. I instantly got this code by using the Record Macro command. Whenever I reach an impass, that's my go-to method.

Lar

Quote from: Pearlitic on January 17, 2017, 07:57:36 PM
I am still having problems with Solid Intersect.
If I remember correctly, in a macro you have to select the 2 solids and enable 'selected only' in the command parameters. Try that see if it helps.

Lar