MarcoW 发表于 2022-7-6 14:21:58

Lisp有点像offset,但是

我想有一个lisp例程,做一些看起来很简单的事情,尽管我自己无法编程。
 
这是它应该做的。
在命令ie.“draw”后,我应该能够绘制一条样条线或样条线,promt(initget pline spline)具有我需要的任意多个点。输入enter时,“定点”停止。在此之前,它都只是一条直线/样条曲线。
 
然后应提示输入第二条pline的侧面,即(initget L R)。或者提示单击与第一条线偏移的所需边,这可能更好。当给定L或R(或在侧面单击)时,应创建第二条样条线/样条线。由于第一条和第二条样条线/样条线属于不同的层和颜色,因此无法使用偏移来完成。
 
它看起来很像偏移量,所以偏移量可能会派上用场。。。?
 
这就是我到目前为止所做的(显然不起作用):
 
 

;;errorhandling when the lisp is ready, do not bother yet

(defun c:draw (); make variables local when lisp ready

(setq pt1 (getpoint "\nGive the first point: ")
pt2 (getpoint "\nGive second point: ")
pt3 (getpoint "\nGive third point: ")
pt4 (getpoint "\nGive fourth point: ")
ss (ssadd) ; Creating an empty selection set
);end of setq

 
我怎样才能根据需要点击尽可能多的点?
现在只有4分可用-这4分必须给!!
 
进入下一步。
顺便说一句,我不喜欢“getpoint”,因为单击时该行不可见。所以我认为“getdist”会有所帮助,但后来我得到了绘制/选择点的奇怪方式。
 

(command "_.pline" pt1 pt2 pt3 pt4 "")
(ssadd (entlast) ss) ; Add the polyline to the selection set

 
我认为ss get比使用“last”更好。
(命令“offset”50 ss)这可以工作,但我不想使用
我想在其他层上创建一条新线的偏移函数。
选择第二条pline应出现的边
 

(initget "L R")
(setq side (getkword "\nSecond line left or right of first line?
(L/R) <R>: "))

 
当与R相同时,只能给出L或R
 

(cond
((= side "L")
(then do this)

;; when given R or <Enter>
;; ------------

(t
(do this
)
(princ)
);end of defun

 
如何把这一切放在一起?

Lee Mac 发表于 2022-7-6 14:29:14

你做了很好的尝试,马可,你有一些好主意。做得好。
 
以下是我的做法,请阅读评论:
 

(defun c:draw (/ *error* vl ov tmp cEnt pt dEnt dObj)
;; Define Function and Localise Variables
;; Don't localise Curv:def, as it remains Global.

(vl-load-com)
;; Load Visual LISP functions - for use later.
;; I find it easier to change object properties
;; using Visual LISP - it can be done in many ways,
;; but this is just my preference.

(or Curv:def (setq Curv:def "Spline"))
;; First time default, as Curv:def will be nil otherwise.


;; Error Handler - as we are tampering with Sys Vars
(defun *error* (msg)
   (if ov (mapcar 'setvar vl ov)) ; Reset Sys Vars
   (if (not
         (wcmatch
         (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
   (princ (strcat "\n<< Error: " msg " >>")))
   (princ))

(setq vl '("CMDECHO" "OSMODE") ; Define a list of Sys Vars
       ov (mapcar 'getvar vl)) ; Retrieve their Settings

(initget "Spline Pline")
(or (not
       (setq tmp
         (getkword (strcat "\nSpline or Pline? <" Curv:def ">: "))))
   (setq Curv:def tmp))

;; Either the user has hit Enter, in which case we don't need to
;; change the value of Curv:def, else, the user has typed something
;; other than that of Curv:def, so we set it as the new default.

(command
   (if (eq Curv:def "Spline") "_.Spline" "_.Pline")) ; Invoke Command

(while (> (getvar "CMDACTIVE") 0) ; Whilst the Command is active
   (command pause)) ; pause for user input

(setq cEnt (entlast)) ; Retrieve newly created Curve

(if (setq pt (getpoint "\nSelect Side of Curve to Offset: "))
   ; If the user selects a point to offset
   
   (progn ; Wrap the following

   (mapcar 'setvar vl '(0 0))
   ;; Turn off OSMODE, as we don't want it to affect the Offset.
   ;; Turn off CMDECHO, as we don't want to see the returns of
   ;; the offset at the command line.

   (command "_.offset" 50 cEnt pt "")
   ;; Perform Offset

   (setq dEnt (entlast))
   ;; Collect Offset Object

   (setq dObj (vlax-ename->vla-object dEnt))
   ;; Convert it to a VLA-OBJECT

   (vla-put-layer dObj "0") ; <<---- Change this to your layer
   ;; Set Object Layer

   ) ; End Progn
   
) ; End IF

(mapcar 'setvar vl ov) ; Reset Sys Vars

(princ)

) ; End Draw


   

 
更改偏移对象的图层。

Lee Mac 发表于 2022-7-6 14:32:28

李,
 
这是惊人的,再次你如何修复它。我已经打印出了在家学习的日程安排。再次谢谢你,你的房子里一定满是谢谢你的。。。
 
在我阅读之前,我想问你,如果我礼貌地问你,你是否愿意加强它。
 
有几件事可以让它更适合我使用。但在讨论这个问题之前,你会尝试修复它吗?
 
其中一件事就是将柱脚的角按一定半径圆角。
 
干杯,伙计。

MarcoW 发表于 2022-7-6 14:40:01

我很乐意帮助您以任何方式更改LISP,只要您从中学习。

Lee Mac 发表于 2022-7-6 14:43:38

2009年5月29日
 
 
f3!

Commandobill 发表于 2022-7-6 14:49:59

 
.... *总部*

Freerefill 发表于 2022-7-6 14:54:40

 
我知道,我知道,但我想让马可从Lisp程序中学习,所以我想让Lisp程序接近他已经掌握的东西。。。
 
顺便说一句,f3?

Lee Mac 发表于 2022-7-6 14:57:06

 
哈哈,这是为了打开和关闭你的osnap。。。“哦,快照”

Commandobill 发表于 2022-7-6 15:03:45

以防万一它在英国不流行
 
“哦,snap”是比兹·马基(Biz Markie)在模仿说唱歌曲《只是一个朋友》(Just a Friend)中使用的一句台词。它有点像俚语,用于侮辱或惊讶之后。”
 
http://wiki.ytmnd.com/Oh_Snap!

Commandobill 发表于 2022-7-6 15:08:09

哈哈哈:哈哈:
页: [1] 2
查看完整版本: Lisp有点像offset,但是