Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Toggle set based on layer on or off

1 REPLY 1
Reply
Message 1 of 2
Dommy2Hotty
228 Views, 1 Reply

Toggle set based on layer on or off

The way this code is supposed to work is as follows:
As the dialog loads, the lisp will check to see if a layer is on. If the layer is on, it will set a variable and check the toggle box. If the layer is not on, the toggle will remain unchecked. When OK is clicked, if the toggle is checked, it will thaw a layer. If the toggle is not checked, it will freeze that layer. That all works fine, except if the layer is already on. If the layer is already on, the toggle will be checked, but if the user clicks OK, the code finishes as if the toggle was not checked. If the user manually unchecks the toggle then checks it again, everything works fine.

***DCL CODE***
[code]RAFB_SUS2_ELECTRICAL : dialog {
label = "<*> Sussex 2 Electrical Options <*>";

: radio_column { label = "< Braced Ceiling Fans >"; key = "BracedCeilingFans";
: toggle { label = "Family Room"; key = "FamilyRoomFan";}
}


: row {
ok_cancel;
}

}// Dialog[/code]
***END DCL CODE***

***LSP CODE***
[code](prompt "\nType RAFB-SUS2-Electrical to run.....");informs user how to run lisp

(defun c:RAFB-SUS2-Electrical ();define function



(setq dcl_id (load_dialog "RAFB-SUS2-Electrical.dcl"));load dialog

(if (not (new_dialog "RAFB_SUS2_ELECTRICAL" dcl_id);test for dialog
);not
(exit);exit if no dialog
);if


;=*=*= FAMILYROOM FAN TEST START =*=*=
(setq test (cdr (assoc 70 (tblsearch "layer" "OPT-CLG FAN-1 STRY FMLY RM-ELEC"))))
(if (or (= test 0))
(progn
(setq FamilyRoomFan "1")
(set_tile "FamilyRoomFan" FamilyRoomFan)
);progn
()
);if
;=*=*= FAMILYROOM FAN TEST END =*=*=


;***** VAR SET START *****
(action_tile "FamilyRoomFan" "(setq FamilyRoomFan (= $value \"1\"))")
;***** VAR SET END *****





(action_tile
"cancel";if cancel button is pressed
"(done_dialog) (setq userclick nil)";close dialog, set flag
);end action_tile

(action_tile
"accept";if O.K. is pressed
"(done_dialog) (setq userclick T))";close dialog, set flag
)

(start_dialog);start dialog
(unload_dialog dcl_id);unload

(if userclick
(progn

(if (= FamilyRoomFan T)(command "-layer" "thaw" "OPT-CLG FAN-1 STRY FMLY RM-ELEC" "")(command "-layer" "freeze" "OPT-CLG FAN-1 STRY FMLY RM-ELEC" ""))

);end progn
);end if
(princ)
);end defun
(princ)[/code]
***END LSP FILE***
1 REPLY 1
Message 2 of 2
Dommy2Hotty
in reply to: Dommy2Hotty

Here are the two files (DCL & LSP).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost