liuhaixin88 发表于 2022-7-5 23:25:14

缺少函数,请帮助!

(defun c:tt (/ i)
(fy:begin)
(setq i 0)
(if (ssget "X" '((0 . "*line,text")))
   (mapcar
   '(lambda (x / str)
      (if (vlax-property-available-p x 'Textstring)
          (and      (setq str (vlax-get x 'textstring))
               (or
               (= str "")
               (= (vl-string-trim " " str) "")
               )
               (setq i (1+ i))
               (vla-delete x)
          )
          (and
            (equal
            (vlax-curve-getdistatparam x (vlax-curve-getendparam x))
            0.0
            1e-3
            )
            (setq i (1+ i))
            (vla-delete x)
          )
      )
      )
   (fy:cset->objs)
   )
)
(if (not (zerop i))
   (princ (strcat "\nTotle Erased " (itoa i) " Lines & text!"))
)
(fy:end)
(princ)
)
 
这还不够!
(defun fy:error      (msg)
(if (and msg (/= msg "Function cancelled"))
   (prompt (strcat "Error: " msg))
   (princ)
)
(fy:end)
(princ)
)
(defun fy:begin      ()
(setq      olderr      *error*
       *error*      fy:error
)
(fy:Clearcset)
(fy:startundo)
t
)
(defun fy:end ()
(fy:unsetv)
(setq      *error*      olderr
       *sysvars* nil
)
(fy:endundo)
(princ)
)

MSasu 发表于 2022-7-5 23:40:27

如果您能随附问题描述,那就太好了。
 
 
在此之前,请注意,您的代码缺少以下函数的定义:
[列表]
[*]fy:cset->objs,
[*]fy:Clearcset,
[*]财年:startundo,
[*]财年:未设置,
[*]fy:endundo。
[/列表]

liuhaixin88 发表于 2022-7-5 23:44:49

添加一个:
(defun fy:clearcset (/ cset)
(if (not (vl-catch-all-error-p
            (setq cset
                   (vl-catch-all-apply
                     'vla-item
                     (list
                     (vla-get-selectionsets (Fy:acDoc))
                     "CURRENT"
                     )
                   )
            )
          )
   )
   (vla-delete cset)
)
(princ)
)

liuhaixin88 发表于 2022-7-5 23:58:40

fy:cset->objs:它应该是转换为对象列表的“ssget”选择集
fy:startundo&fy:endundo可能是“command undo be”
fy:未设置可能是恢复保存的原始系统变量
 
有人能帮我吗

MSasu 发表于 2022-7-6 00:01:29

刘海欣88,愿意帮助你的人并不短缺,但必须首先明确说明你需要什么样的帮助!
你想让别人帮你写那些缺失函数的代码?!?

liuhaixin88 发表于 2022-7-6 00:08:10

 
我想有人写的代码,这些缺失的功能为我!
(defun fy:cset->objs (/ el)
(vlax-for obj (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
   (setq el (cons obj el))
)
el
)
(defun fy:startundo ()
(vla-startundo (vla-get-activedocument (vlax-get-acad-object)))
)
(defun fy:endundo ()
(vla-endundo (vla-get-activedoument (vlax-get-acad-object)))
)

liuhaixin88 发表于 2022-7-6 00:18:26

 
为什么还是跑不动
(vl-load-com)
(defun c:tt (/ i)
(fy:begin)
(setq i 0)
(if (ssget "X" '((0 . "*line,text")))
   (mapcar
   '(lambda (x / str)
      (if (vlax-property-available-p x 'Textstring)
          (and      (setq str (vlax-get x 'textstring))
               (or
               (= str "")
               (= (vl-string-trim " " str) "")
               )
               (setq i (1+ i))
               (vla-delete x)
          )
          (and
            (equal
            (vlax-curve-getdistatparam x (vlax-curve-getendparam x))
            0.0
            1e-3
            )
            (setq i (1+ i))
            (vla-delete x)
          )
      )
      )
   (fy:cset->objs)
   )
)
(if (not (zerop i))
   (princ (strcat "\nTotle Erased " (itoa i) " Lines & text!"))
)
(fy:end)
(princ)
)

(defun fy:begin      ()
(setq      olderr      *error*
       *error*      fy:error
)
(fy:Clearcset)
(fy:startundo)
t
)
(defun fy:end ()
(unsetv)
(setq      *error*      olderr
       *sysvars* nil
)
(fy:endundo)
(princ)
)

(defun fy:clearcset (/ cset)
(if (not (vl-catch-all-error-p
            (setq cset
                   (vl-catch-all-apply
                     'vla-item
                     (list
                     (vla-get-selectionsets (Fy:acDoc))
                     "CURRENT"
                     )
                   )
            )
          )
   )
   (vla-delete cset)
)
(princ)
)

(defun fy:cset->objs (/ el)
(vlax-for obj (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
   (setq el (cons obj el))
)
el
)
(defun fy:startundo ()
(vla-startundo (vla-get-activedocument (vlax-get-acad-object)))
)
(defun fy:endundo ()
(vla-endundo (vla-get-activedoument (vlax-get-acad-object)))
)

(defun setv (name value / oldval)
(setq oldval (getvar name))
(if (not (assoc name *sysvars*))
   (setq *sysvars* (append *sysvars* (list (cons name oldval))))
)
(setvar name value)
oldval
)
(defun unsetv ()
(foreach v *sysvars* (setvar (car v) (cdr v)))
)
(defun Fy:acDoc    nil
(eval    (list 'defun
         'FY:acdoc
         'nil
         (vla-get-activedocument (vlax-get-acad-object))
   )
)
(fy:acdoc)
)

Snownut 发表于 2022-7-6 00:26:08

为什么不从部分原始代码的源代码中获取完整的代码。。。。。
页: [1]
查看完整版本: 缺少函数,请帮助!