ROHO
M
200
-325,0,0
325,0,0
(defun c:rs()
(setvar 'expert 2)
(SETQ FLT '((-4 . "<AND")
(0 . "insert")
(8 . "*577*")
(-4 . "AND>")
)
)
(setq ss (ssget "x" flt))
(setq cnt 0)
(foreach x (ss->list ss)
(setq what (get_xdata_tl x "SubType.Descr")
shape(get_xdata_tl x "Shape.Descr")
sys (get_xdata_tl x "PipeDef.Descr"))
(cond( (and (= what "Luchtkanaal")(= shape "Rond"))
(setq l (get_xdata_tl x "Length")
dia(get_xdata_tl x "SizeDescr"))
(cond ((= sys "Lucht toevoer" )
( setq slw "T"))
((= sys "Lucht retour" )
( setq slw "R")))
(make_script (strcat "ROHO_M_" dia "_" (rtos (- 0 (/ l 2))2 0)",0,0_"(rtos (/ l 2)2 0)",0,0 "))
(command "ucs" "ob" x "")
(command "script" script)
(+cnt)
))
))
(defun make_script(string)
(setq path (vl-filename-directory
(findfile "integraal_ontwerpen.odcl")
) ;_ end of vl-filename-directory
)
(vl-file-delete script)
(setq script (strcat path "\\script"(itoa cnt) ".scr"))
(setq scr (open script "W"))
(setq strings (split string "_"))
(foreach y strings
(write-line y scr)
)
(close scr)
)
_.open "c:\drawing0.dwg"
rs
_.qsave _.close
_.open "c:\drawing1.dwg"
rs
_.qsave _.close
_.open "c:\drawing2.dwg"
rs
_.qsave _.close
(command "roho" "m" (list 0 0 0) (list 500 0 0) "")
but the code of their old version is in lisp and needs the input prompt during the command. but even if i replace i try for the sake of testing to draw a line with the script it won't execute, it runs through the ss, does the ucs stuff but no line is drawn.
(defun c:rs()(if (setq ss (ssget "x" '((-4 . "<AND") (0 . "insert") (8 . "*577*") (-4 . "AND>"))))
(progn (setq file (strcat (getvar 'dwgprefix) "temp.scr"))
(setvar 'filedia 0)
(foreach x (ss->list ss)
(setq what (get_xdata_tl x "SubType.Descr")
shape (get_xdata_tl x "Shape.Descr")
sys (get_xdata_tl x "PipeDef.Descr")
)
(cond ((and (= what "Luchtkanaal") (= shape "Rond"))
(setq l (get_xdata_tl x "Length")
dia (get_xdata_tl x "SizeDescr")
)
(cond ((= sys "Lucht toevoer") (setq slw "T"))
((= sys "Lucht retour") (setq slw "R"))
)
(setq fo (open file "W"))
(write-line "_.line" fo)
;;;
;;; (write-line "M" fo)
;;;
;;; (write-line (vl-princ-to-string dia) fo)
(write-line (strcat (rtos (- 0 (/ l 2.)) 2 0) ",0,0") fo)
(write-line (strcat (rtos (/ l 2.) 2 0) ",0,0 ") fo)
(close fo)
(command "_.ucs" "ob" x "")
(command "_.script" file)
)
)
)
(setvar 'filedia 1)
(and (findfile file) (vl-file-delete file))
)
)
(princ)
)
Ron,
same thing, same result unfortunately. Now you write the script in the same function, but it stops after the first script. look s like the script is still running while the lisp already wants to rewrite the script (remember, you use the same name.) This is why i tried to make different scripts (wit ha counter) but the no script gets executed. it seems to me tha tyou can't run multiple script in a lisp, because the cmdactive stays at 4 (script) i tried everything i put in a command after the script, a while with cmdactive 4 (that loop never ends). so i don't l know. i attached the code change to make it draw a line (because yo udon't have the roho command) and the drawing, so you give it a test if you feel like. maybe it is something on my computer, setting or so.
Thanks BerndCode: [Select](defun c:rs()(if (setq ss (ssget "x" '((-4 . "<AND") (0 . "insert") (8 . "*577*") (-4 . "AND>"))))
(progn (setq file (strcat (getvar 'dwgprefix) "temp.scr"))
(setvar 'filedia 0)
(foreach x (ss->list ss)
(setq what (get_xdata_tl x "SubType.Descr")
shape (get_xdata_tl x "Shape.Descr")
sys (get_xdata_tl x "PipeDef.Descr")
)
(cond ((and (= what "Luchtkanaal") (= shape "Rond"))
(setq l (get_xdata_tl x "Length")
dia (get_xdata_tl x "SizeDescr")
)
(cond ((= sys "Lucht toevoer") (setq slw "T"))
((= sys "Lucht retour") (setq slw "R"))
)
(setq fo (open file "W"))
(write-line "_.line" fo)
;;;
;;; (write-line "M" fo)
;;;
;;; (write-line (vl-princ-to-string dia) fo)
(write-line (strcat (rtos (- 0 (/ l 2.)) 2 0) ",0,0") fo)
(write-line (strcat (rtos (/ l 2.) 2 0) ",0,0 ") fo)
(close fo)
(command "_.ucs" "ob" x "")
(command "_.script" file)
)
)
)
(setvar 'filedia 1)
(and (findfile file) (vl-file-delete file))
)
)
(princ)
)