News:

Please note new Forum URL: forum.designcad.com

Main Menu

Toggle Layer Visibility

Started by Gymbo, May 18, 2020, 01:23:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Gymbo

Hi,

I wrote a macro that toggles layer visibility momentarily. Not sure why anyone but me would want such a thing but here it is. I would not recommend using it close to the top of the hour, other than that it should be fairly accurate up to about 10 seconds.

'T3.dm3
'by Gymbo
'toggle layer visibility momentarily
'5/16/20

precision 0

num = 3                 'layer number
visible = 2            'seconds to keep visible
final = 5000          'final value of For..Next counter

y = layer(num)

if  ODD(y\2) = 1 then   'layer already visible
    sys(1027) = 4       'yes/no messagebox style
    Msg$ = "Do you want it invisible?"
    message "Layer", num, "is already visible. ", msg$

    if sys(1028) = 6 then      'yes
        layer(num) = 0         'visible and editable
        >regenerate
        {
        }
    endif
    end
else                     'is not visible
    layer(num) = 6       'visible and editable
    >regenerate
    {
    }
    T$ = sys$(7)        'hh:mm:ss
    gosub convert   
     s = n
    for i = 1 to final  'increase if required
        t$ = sys$(7)
        for h = 1 to 50  'use up some time
          x = PI/4
          x1 = atan(-x / sqrt(-x * x +1) + 2 * atan(1))
        next
        gosub convert
        f = n       
        d = abs(f - s)
        if d >= visible then  'keep visible for 'visible' seconds
           layer(num) = 0     'make it invisible
           >regenerate
           {
           }
           oh = 1           'skip message
           exit for
        endif   
    next
    if oh <> 1 then
        newFinal = visible * final / d
        message "Increase final to >", newFinal
        layer(num) = 0     'make it invisible
        >regenerate
        {
        }       
    endif
end if
' print d, i
' anykey
end

convert:
'convert hh:mm:ss to mmss
a$ = right$(t$, 5)      'mm:ss
b$ = left$(a$, 2)       'mm
c$ = right$(a$, 2)      'ss
d$ = b$ + c$            'mmss
n = val(d$)
return
Regards,

Jim