Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun hello ()
- (setq dcl_id (load_dialog "f:\\work\\dialog.dcl") dx_on "0.1" dy_on "0.1" out "0" n 8)
- (while (< 2 n)
- (if(not(new_dialog "hello" dcl_id)) (exit))
- (set_tile "dx" dx_on)
- (set_tile "dy" dy_on)
- (set_tile "Out" out)
- (action_tile "dx" "(setq dx_on $value)")
- (action_tile "dy" "(setq dy_on $value)")
- (action_tile "calc" "(fOne)")
- (action_tile "accept" "(fTwo)(done_dialog 1)")
- (setq n (start_dialog))
- )
- (unload_dialog dcl_id)
- )
- (defun fOne ()
- (setq nabor (ssget "X" '((0 . "LINE"))))
- (setq size (sslength nabor))
- (setq i 0 n1 0 n2 0)
- (setq fdx (atof dx_on) fdy (atof dy_on))
- (while (< i size)
- (setq P (ssname nabor i))
- (setq prim (entget P))
- (setq startL (assoc 10 prim))
- (setq endL (assoc 11 prim))
- (setq start (cdr startL)) ;êîîðäèíòû íà÷àëà
- (setq end (cdr endL)) ;êîîðäèíàòû êîíöà
- (setq xs (car start)) ;X êîîðäèíàòà íà÷àëà
- (setq ys (cadr start)) ;Y êîîðäèíàòà íà÷àëà
- (setq xe (car end)) ;X êîîðäèíàòà êîíöà
- (setq ye (cadr end)) ;Y êîîðäèíàòà êîíöà
- (setq newxe xe)
- (setq newye ye)
- (setq vX (abs (- xs xe)))
- (setq vY (abs (- ys ye)))
- (cond
- ((< vX fdx) (progn (setq newxe xs) (setq n1 (+ 1 n1)))) ;íîâîå çíà÷åíèå X êîíöà îòðåçêà, åñëè TRUE
- ((< vY fdy) (progn (setq newye ys) (setq n2 (+ 1 n2)))) ;íîâîå çíà÷åíèå Y êîíöà îòðåçêà, åñëè TRUE
- )
- (setq i (+ 1 i))
- )
- (setq sum (+ n1 n2))
- (set_tile "Out" (itoa sum))
- )
- (defun fTwo ()
- (setq nabor (ssget "X" '((0 . "LINE"))))
- (setq size (sslength nabor))
- (setq j 0)
- (setq fdx (atof dx_on))
- (setq fdy (atof dy_on))
- (while (< j size)
- (setq P (ssname nabor j))
- (setq prim (entget P))
- (setq startL (assoc 10 prim))
- (setq endL (assoc 11 prim))
- (setq start (cdr startL)) ;êîîðäèíòû íà÷àëà
- (setq end (cdr endL)) ;êîîðäèíàòû êîíöà
- (setq xs (car start)) ;X êîîðäèíàòà íà÷àëà
- (setq ys (cadr start)) ;Y êîîðäèíàòà íà÷àëà
- (setq xe (car end)) ;X êîîðäèíàòà êîíöà
- (setq ye (cadr end)) ;Y êîîðäèíàòà êîíöà
- (setq newxe xe)
- (setq newye ye)
- (setq vX (abs (- xs xe)))
- (setq vY (abs (- ys ye)))
- (cond
- ((< vX fdx) (setq newxe xs)) ;íîâîå çíà÷åíèå X êîíöà îòðåçêà, åñëè TRUE
- ((< vY fdy) (setq newye ys)) ;íîâîå çíà÷åíèå Y êîíöà îòðåçêà, åñëè TRUE
- )
- (setq new_end (list 11 newxe newye 0.0)) ;ñîçäàíèå íîâîãî ñïèñêà êîîðäèíàò êîíöà
- (setq prim (subst new_end endL prim)) ;çàìåíà ñòàðîãî ñïèñêà ñ êîîðäèíàòàìè êîíöà ïðåîáðàçîâàííûì
- (entmod prim) ;ïðèìåíåíèå èçìåíåíèé
- (entupd P)
- (setq j (+ 1 j))
- )
- )
- (hello)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement