本帖最后由 作者 于 2009-11-30 8:07:01 编辑
這個功能我好像有發過(但找不到...重發) ;;給個思路,如何實現實體沿Spline曲線"動態"移動? ;;前幾日下載lcsfm樓主的機械標注工具程式,試用後發現其在程式中生成的 ;;實體如粗糙度(無名塊),在未確定標注點前可沿實體如Spline曲線"動態" ;;移動,在移動過程中隨曲線變化可隨時變換粗糙度方向,這一功能如何在 ;;Lisp程式中實現,請大家給個思路...... ;;BY LUCAS(龍龍仔) ;;只把沿曲線"動態"移動寫出,希望你能把它完整寫出 ;;需配合"123"圖塊(附件) (defun C:BB (/ ANG BOOLEAN CODE CURVE-OBJ ENT MOTION PT PT1 PT2) (vl-load-com) (setq CURVE-OBJ (vlax-ename->vla-object (car (setq ENT (entsel "\nSelect Curve: "))) ) ) (setq ANG (angle '(0 0 0) (vlax-curve-getfirstderiv CURVE-OBJ (vlax-curve-getparamatpoint CURVE-OBJ (setq PT2 (osnap (cadr ENT) "NEA")) ) ) ) ) (command "_.INSERT" "BB" PT2 "10" "" (/ (* ANG 180) pi)) (setq BOOLEAN t) (setq ENT (entget (entlast))) (while BOOLEAN (setq MOTION (grread t 15 0)) (setq CODE (car MOTION)) (cond ((= CODE 5) ;滑鼠遊移 (setq PT (cadr MOTION)) (if (not (equal PT PT2)) (progn (setq PT1 (vlax-curve-getclosestpointto CURVE-OBJ PT)) (setq ENT (subst (cons 10 PT1) (assoc 10 ENT) ENT)) (setq ANG (+ (* 1.5 pi) (angle PT1 PT))) (setq ENT (subst (cons 50 ANG) (assoc 50 ENT) ENT)) (setq ENT (entmod ENT) PT2 PT ) ) ) ) ((= CODE 3) ;滑鼠左鍵按下 (setq BOOLEAN NIL) ) ) ) (princ) ) |