天之如一 发表于 2024-8-25 18:16:59

请教下这段代码有什么问题,为啥用list就报错



;;多段线相对点计算函数
(defun createPline (basepoint points arc-pt-value-list / i temp )
(vl-load-com)
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
(setq modelSpace (vla-get-ModelSpace doc))
;; 创建多段线
(setq i 0)
(setq ptlist nil )
(while (<= i (- (length points) 1)) ;;相对点计算
      (setq point (nth i points))
    (setq point-new (mapcar '+ basepoint point))
      (setq ptlist (cons point-new ptlist))
      (setq i (1+ i))
   )
(setq temp (apply 'append ptlist ))
(setq points (vlax-make-safearray vlax-vbDouble (cons 0 (- (length temp) 1))))
(vlax-safearray-fill points temp )
;; 创建多段线
(setq plineObj (vla-addPolyline modelSpace points))
;;多断线设置多点凸度值
(set-convexity-for-multiple-points plineObj arc-pt-value-list )
)
;;设置多点凸度值函数
(defun set-convexity-for-multiple-points (plineObj arc-pt-value-list / a temp )
(setq a 0)
(if (/= nil arc-pt-value-list )
                     (repeat (length arc-pt-value-list)
      
      (progn
            (setq temp ( nth a arc-pt-value-list)
            arc-pt (nth 0 temp)
            arc-value (nth 1 temp))
      (vla-setBulge plineObj arc-pt arc-value)
      (setq a ( + 1 a))
       )
   )   
)
)
;;绘制扶梯主程序
(defun c:tt ()
(setq bp (getpoint "\n确定基点:"))
(setq top-length (getreal "\n请确定上水平长度")
   (setq pts1 '(
                (-2826 0 0)
                (-2846.31 106.185 0)
                (-2827.908 2000)
                (-2797.37 2500)
                (-2776 250 0 )
                (-2776 1500)
                (-2776 0 0)
                )
   )
   (setq line11 (createPline bp pts1 '(
                                       (3 0.2)
                                       )
                )
   )
;;创建直线1-2
    (setq pts2 '(
               (-2797.37 250 0)
               (-2876 250 0)
               (-2876 950 0)
               (-829 950 0)
               (820.3194 507.8838 0)
               )
    )
   (setq line12 (createPline bp pts2 '(
                                       (0 0.1325)
                                       (2 1)
                                       )
                )
   )
;;创建直线1-3
   (setq pts3 '(
                (-2827.908 200 0)
                (-2876 200 0)
                (-2876 1000 0)
                (-816.2831 1000 0)
                (833.7169 557.8838 0)
                )
   )
   (setq line13 (createPline bp pts3 '(
                                       (0 0.1325)
                                       (2 1)
                                       )
                )
   )
;;创建直线1-4
   (setq pts4 '(
                (-2776 150 0)
                (-193.7822 150 0)
                )
   )
   (setq line14 (createPline bp pts4 '(
                                       (0 0)
                                       )
                )
   )
;; 创建直线top-linex1
    (setqptsx1 (list
                  '(0 0 0)
                  ( list ((- ( - top-length) 250)) 0 0)
                  ( list ((- ( - top-length) 250)) -80 0)
                  ( list ((+ ( - top-length) 250)) -80 0)
                  ( list ((+( - top-length) 250)) 0 0)
                )
    )
;; 创建直线top-linex2
    (setqptsx2(list
                   ( list ((+ ( - top-length) 50)) -80 0)
                   ( list ((+(-top-length) 50))-1305 0)
                   ( 296.3263 -1305.0000 0)
                   )
    )
    (setq top-linex2 (createPline bp ptsx2 '(
                                             (0 0)
                                             )
                     )
    )
;; 创建直线top-linex3
    (setqptsx3(list
                   (list (- top-length) -80 0)
                   (list (- top-length) -1700 0)
                   )
    )
    (setq top-linex3 (createPline bp ptsx3 '(
                                             (0 0)
                                             )
                     )
    )
)








飞雪神光 发表于 2024-8-25 20:51:54

;;绘制扶梯主程序
(defun c:tt ()
(setq bp (getpoint "\n确定基点:"))
        (setq top-length (getreal "\n请确定上水平长度"))
        (setq pts1 '(
                                                                (-2826 0 0)
                                                                (-2846.31 106.185 0)
                                                                (-2827.908 2000)
                                                                (-2797.37 2500)
                                                                (-2776 250 0 )
                                                                (-2776 1500)
                                                                (-2776 0 0)
                                                        )
        )
        (setq line11 (createPline bp pts1 '(
                                                                                                                                                       (3 0.2)
                                                                                                                                               )
                                                       )
        )
        ;;创建直线1-2
        (setq pts2 '(
                                                                (-2797.37 250 0)
                                                                (-2876 250 0)
                                                                (-2876 950 0)
                                                                (-829 950 0)
                                                                (820.3194 507.8838 0)
                                                        )
        )
        (setq line12 (createPline bp pts2 '(
                                                                                                                                                       (0 0.1325)
                                                                                                                                                       (2 1)
                                                                                                                                               )
                                                       )
        )
        ;;创建直线1-3
        (setq pts3 '(
                                                                (-2827.908 200 0)
                                                                (-2876 200 0)
                                                                (-2876 1000 0)
                                                                (-816.2831 1000 0)
                                                                (833.7169 557.8838 0)
                                                        )
        )
        (setq line13 (createPline bp pts3 '(
                                                                                                                                                       (0 0.1325)
                                                                                                                                                       (2 1)
                                                                                                                                               )
                                                       )
        )
        ;;创建直线1-4
        (setq pts4 '(
                                                                (-2776 150 0)
                                                                (-193.7822 150 0)
                                                        )
        )
        (setq line14 (createPline bp pts4 '(
                                                                                                                                                       (0 0)
                                                                                                                                               )
                                                       )
        )
        ;; 创建直线top-linex1
        (setqptsx1 (list
                                                               '(0 0 0)
                                                               (list (- (- top-length) 250) 0 0)
                                                               (list (- (- top-length) 250) -80 0)
                                                               (list (+ (- top-length) 250) -80 0)
                                                               (list (+(- top-length) 250) 0 0)
                                                       )
        )
        ;; 创建直线top-linex2
        (setqptsx2(list
                                                                        (list (+ ( - top-length) 50) -80 0)
                                                                        (list (+(- top-length) 50)-1305 0)
                                                                        '(296.3263 -1305.0000 0)
                                                                )
        )
        (setq top-linex2 (createPline bp ptsx2 '(
                                                                                                                                                                                (0 0)
                                                                                                                                                                        )
                                                                       )
        )
        ;; 创建直线top-linex3
        (setqptsx3(list
                                                                        (list (- top-length) -80 0)
                                                                        (list (- top-length) -1700 0)
                                                                )
        )
        (setq top-linex3 (createPline bp ptsx3 '(
                                                                                                                                                                                (0 0)
                                                                                                                                                                        )
                                                                       )
        )
)

寒潮大冬瓜 发表于 2024-8-26 14:31:58

很好→很棒!很好~很棒!!很好……很棒!!!

天之如一 发表于 2024-8-26 16:26:45

飞雪神光 发表于 2024-8-25 20:51


怎么使用这个编辑器啊,为啥我没有

飞雪神光 发表于 2024-8-26 16:46:24

编辑器是飞诗 显示效果是 在编辑框上 的 <> 这个东西里面

天之如一 发表于 2024-8-26 17:11:08

飞雪神光 发表于 2024-8-26 16:46
编辑器是飞诗 显示效果是 在编辑框上 的这个东西里面

噢噢噢噢,谢谢。。。。
页: [1]
查看完整版本: 请教下这段代码有什么问题,为啥用list就报错