How to add IF statement to toolbar button macro?

How to add IF statement to toolbar button macro?

johnw
Collaborator Collaborator
852 Views
2 Replies
Message 1 of 3

How to add IF statement to toolbar button macro?

johnw
Collaborator
Collaborator

I have the following macro for one of my toolbar buttons to set my layer to ELEC and then insert a symbol (that portion not shown here). How would I add an IF statement that would check my current layer to see if it was OPTELEC and if so insert my symbol), or if not OPTELEC, go ahead and insert it on ELEC layer.

 

^C^C.-layer;m;elec;;insert;bla-bla-bla

 

Thanks,

 

John

 

 

 

 

 

0 Likes
Accepted solutions (1)
853 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

(if (/= (getvar "clayer") "OPTELEC")

    (progn

        (set yourlayer current and insert your block)

    );;else

    (insert your block)

);;if

 

 

Message 3 of 3

Anonymous
Not applicable

A simple library routine would be easiest just ask does layer exists if not make, autoload on start up.

 

(laychk "elec" 6 "continous")
(defun laychk ( lay col lt /)
(if (= (tblsearch "layer" lay) T)
(setvar 'clayer lay)
(command "-layer" "M" lay "C" col lay "lt" lt lay "")
)
)
0 Likes