曾在mjtd论坛中看到这样的一个程序(龙龙仔编,见下面),但是有几点不明白的地方,请帮忙!
我的问题是:
1-------怎么控制螺旋线的起点和终点?(若不可控制,请完善)
2-------我想用"revolve"命令以此螺旋线为扫描路径,扫描一出一个螺纹实体,但总是提示“Axis must be a line or a polyline.”,是不是因为螺旋线是3dpoly,“revolve”命令不支持?
3-------请给出常用的扫描相关的命令
4-------我的方法可行否?若可行,如何实现?
请各位前辈指点一下,不胜感激!
程序如下:
- ;;BY LUCAS(龙龙仔)
- ;;将spline等分为n个弧,再转为pline
- ;;只对2D spline有效, 3D spline要改用3dpoly
- (defun C:SPLINE_TO_PLINE (/ HOLDECHO OS SSS NUMPT N
- ED ED1 PTST PTEND SS2 PT1 PT2
- PT3 J ENT NNO SS SSL
- )
- (defun VAL1 (N SS INDEX)
- (cdr (assoc N (entget (ssname SS INDEX))))
- )
- (defun CH_IT (NOS)
- (if (assoc NOS ED)
- (progn
- (if (assoc NOS ENT)
- (setq ENT (subst (assoc NOS ED) (assoc NOS ENT) ENT))
- (setq ENT (append ENT (list (assoc NOS ED))))
- )
- (entmod ENT)
- )
- )
- )
- (setq HOLDECHO (getvar "cmdecho"))
- (setvar "cmdecho" 0)
- (command "_.undo" "group")
- (setq OS (getvar "osmode"))
- (setvar "osmode" 0)
- (prompt "\nPlease pick the spline: ")
- (setq SSS (ssget '((0 . "spline"))))
- (if SSS
- (progn
- (initget (+ 1 2 4))
- (setq NUMPT
- (getint
- "\nPlease specify the accuracy of conversion: "
- )
- )
- (setq N 0)
- (setq SSL (sslength SSS))
- (repeat SSL
- (prompt (strcat "\r余 " (itoa (- SSL N)) " 个物件 "))
- (setq ED1 (ssname SSS N))
- (setq ED (entget ED1))
- (setq PTST (cdr (assoc 10 ED))
- PTEND (cdr (assoc 10 (reverse ED)))
- )
- (command "_.divide" ED1 (* 2 NUMPT))
- (setq SS2 (ssget "p"))
- (if (= (logand (cdr (assoc 70 ED)) 1) 1)
- (setq J 1)
- (setq J 0)
- )
- (setq PT3 PTST)
- (setq SS (ssadd))
- (repeat NUMPT
- (setq PT2 (VAL1 10 SS2 J))
- (if (/= NUMPT (/ (+ J 2) 2))
- (setq PT1 (VAL1 10 SS2 (+ 1 J)))
- (setq PT1 PTEND)
- )
- (command "_.arc" PT3 PT2 PT1)
- (ssadd (entlast) SS)
- (setq PT3 PT1)
- (setq J (+ 2 J))
- )
- (command "_.pedit" (ssname SS 1) "" "j" SS "" "")
- (setq ENT (entget (entlast)))
- (foreach NNO '(6 8 62 48)
- (CH_IT NNO)
- )
- (command "_.erase" SS2 ED1 "")
- (setq N (1+ N))
- )
- (prompt (strcat "\r完成转换 ")
- )
- )
- (alert "Nothing selected!!")
- )
- (setvar "osmode" OS)
- (command "_.undo" "end")
- (setvar "cmdecho" HOLDECHO)
- (princ)
- )
|