harrison-matt 发表于 2022-7-6 10:17:07

Getstring问题

全部的
 
我很难让Getstring函数不允许空白的“”返回。我已经尝试了(initget 1),但这对于getstring函数不起作用。这是我的getstring:
 
(setq strg (getstring T "\nBox Content"))
 
我试着用while循环,因为当按enter时命令不会返回nil,所以它进入了一个循环,迫使我结束任务。然后我尝试了康德,同样的事情。。
 
有什么建议吗?
谢谢
 
马特

harrison-matt 发表于 2022-7-6 10:21:10


(setq pt1 (getpoint "\nFirst corner of box:"))
(initget 32)
(setq pt2 (getcorner pt1 "\nFinal corner of box: "))
(setq inside (getstring T "\nContents within box: "))
(setq ang (angtos (angle pt1 pt2) 0 )

 
为什么会循环?我很困惑

BlackBox 发表于 2022-7-6 10:24:30

也许这将有助于:
 

(defun c:FOO (/ pt1 pt2 inside ang)
(if (setq pt1 (getpoint "\nFirst corner of box:"))
   (progn
   (initget 32)
   (setq pt2 (getcorner pt1 "\nFinal corner of box: "))
   (if (setq inside (getstring T "\nContents within box: "))
       (while (= "" inside)
         (setq inside (getstring T "\nInvalid Input, Enter Contents within box: "))))
   (setq ang (angtos (angle pt1 pt2) 0 )
   ;; ...Code
   ))
(princ))

Lt Dan's l 发表于 2022-7-6 10:28:38


(setq ang
(angtos
   (angle (setq pt1 (getpoint "\nFirst corner of box:"))
            (setq pt2 (getcorner pt1 "\nFinal corner of box: "))
   )
   0 8
)
)
(initget 32)
(while
(eq (setq inside (getstring T "\nContents within box: ")) "")
(prompt "\nPlease type in something!!!!!")
)

alanjt 发表于 2022-7-6 10:31:52

(and (setq pt1 (getpoint "\nFirst corner of box:"))
    (setq pt2 (getcorner pt1 "\nFinal corner of box: "))
    (/= "" (setq inside (getstring T "\nContents within box: ")))
    (setq ang (angtos (angle pt1 pt2) 0 )
)

harrison-matt 发表于 2022-7-6 10:34:38

谢谢你的帮助!,我还有一个问题,我想我会把它贴在这里,而不是创建一个新的thead。
Visual lisp问题:
 
我试图使用VLA-ADDTEXT放置文本,但出现以下错误:
“lisp值不强制此类型的变体:(5.59997 12.8634 0.0)”
 

(vl-load-com)
(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
   spc (if (zerop (vla-get-activespace doc))
    (if (= (vla-get-mspace doc) :vlax-true)
      (vla-get-modelspace doc)
      (vla-get-paperspace doc))
    (vla-get-modelspace doc)))

(if (setq inside (getstring T "\nContents within box: "))
(while (= "" inside)
   (setq inside (getstring T "\nInvalid Input, Enter Contents within box: "))))
(setq begin (getpoint "\nCenter of Cell: "))
(VLA-ADDTEXT spc INSIDE BEGIN 0.09375)

 
有什么想法吗?
马特

alanjt 发表于 2022-7-6 10:37:22

(vlax-3d-point )

Lt Dan's l 发表于 2022-7-6 10:42:13

尝试
(rtos begin 2 5)

BlackBox 发表于 2022-7-6 10:43:24

 
为什么?
 

Command: (setq begin (list 5.59997 12.8634 0.0))
(5.59997 12.8634 0.0)

Command: (rtos begin 2 5)
; error: bad argument type: numberp: (5.59997 12.8634 0.0)

Lee Mac 发表于 2022-7-6 10:46:47

另一个可能的角度来接近它。。。
 

(defun c:test ( / inside begin ) (vl-load-com)

(while (= "" (setq inside (getstring t "\nContents Within Box: ")))
   (princ "\n** You're doing it wrong **")
)

(if (setq begin (getpoint "\nPick that Center: "))
   (vla-AddText
   (vlax-get-property (vla-get-ActiveDocument (vlax-get-acad-object))
       (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace)
   )
   inside (vlax-3D-point begin) 0.09375
   )
)

(princ)
)
页: [1] 2
查看完整版本: Getstring问题