View Full Version : LISP to VLISP - Building Reactors, what is the best approach?
madcadder
2007-03-12, 06:38 PM
I have this piece of code:
(IF (NOT (TBLSEARCH "layer" "Z-ANNO-DIMS"))
(COMMAND "_.-layer" "_make" "Z-ANNO-DIMS" "_color" "1" "Z-ANNO-DIMS"
""
) ;_ end of COMMAND
(COMMAND "_.-layer" "_thaw" "Z-ANNO-DIMS" "_on" "Z-ANNO-DIMS" "_set"
"Z-ANNO-DIMS" ""
) ;_ end of COMMAND
) ;_ end of IF
Thanks to a direction provided by CCOWGIL I am rewriting a routine to use reactors. (Fingers crossed. This is a first)
One thing I noticed is the reactor bombs on using COMMAND, so I need another way to do the exact same thing without using COMMAND.
Any guidance is appreciated.
Thanks,
I have this piece of code:
Thanks to a direction provided by CCOWGIL I am rewriting a routine to use reactors. (Fingers crossed. This is a first)
One thing I noticed is the reactor bombs on using COMMAND, so I need another way to do the exact same thing without using COMMAND.
Any guidance is appreciated.
Thanks,
Hi Tod,
You are correct; command is a no-no in reactors.
You might be able to modify this to do what you want. I would probaly remove the alert for what you are doing, and maybe make it set the layer if it exists. At least it will show how to create a layer with VL. BTW, thanks to T.Willey for helping with the linetype portion.
(defun layermake (lname lcolor ltype lnoplot / oblay ltcol)
(vl-load-com)
(if (not (tblsearch "LAYER" lname))
(progn
(or *acaddoc* (setq *acaddoc* (vla-get-activedocument (vlax-get-acad-object))))
(setq oblay (vla-add (vla-get-layers *acaddoc*) lname)
ltcol (vla-get-Linetypes *acaddoc*)
)
(vla-put-color oblay lcolor)
(if lnoplot
(vla-put-plottable oblay acFalse)
)
(if
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Item (list ltcol ltype)))
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-Load (list ltcol ltype "acad.lin")))
nil
T
)
T
)
(vla-put-linetype oblay ltype)
(progn
(alert (strcat
"\nLinetype "
(strcase ltype)
" not found in drawing or acad.lin.\nContinuous used."))
(vla-put-linetype oblay "CONTINUOUS")
)
);if
);progn
);if
);defun
Example: (layermake "test1" "3" "dashed" nil)
HTH
madcadder
2007-03-12, 08:00 PM
Not bad. I can work (learn) from that and take care of the IF part.
So far.. I have modified the code provided to set the layer, linetype, color, and plot to create if needed.
I still need something that would take care of the IF NOT and resolve the THAW and the ON, but you got me started in a good direction.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.