乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: Lee Mac

[编程交流] 中线LISP错误

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 17:55:59 | 显示全部楼层
Hey CALCAD, CAB,
 
I just tried your LISP CAB, and I must say, you have tidied up my LISP beautifully... I'm loving that (or) statement in place of the (if(not))... I don't know how you think of these things
 
Your LISP functions well and my layer is successfully reset. I can only imagine that the Error Handler in my original code clashed with my lines that reset the current layer.
 
But it works now and thanks to CAB and CALCAD for both your help - all is much appreciated - I just hope I can return the favour at some point
回复

使用道具 举报

10

主题

109

帖子

99

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 18:02:14 | 显示全部楼层
You're welcome Lee.
回复

使用道具 举报

40

主题

132

帖子

107

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
227
发表于 2022-7-6 18:03:09 | 显示全部楼层
HEY LEE MAC IT'S ME 'JTP'
 
I'm intersted in you program sounds cool .
does the drawing have to be active to work ??
I Don't really have anything to add to this post .
just thought is was cool we are, friends and your on the other side of the world .
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 18:08:05 | 显示全部楼层
Hey JTP,
 
Yeh it is pretty cool that people from all over the world share programs they have created.
 
My program is just for adding Centre-lines to circles, after the user has set a base variable - namely the ratio of the line to the radius of the circle (preset at 122%).
 
The drawing does have to be active, and the user selects the circles one by one, until hitting either "enter" or "esc" to exit the function.
 
Here is the final version:  
 
  1. ;|         Centre-Line by Lee McDonnell               November 2008 Credit to CALCAD & CAB for Help with Development|;(defun c:cl (/ oldlay oldsnap c1 c1ent c1cent c1rad crat            *error* ; always localize the error handler            )         ;     --- Error Trap --- (defun *error* (msg)        (mapcar 'setvar varLst oldVars)   (if (= msg "")         (princ "\nUser Quit... ")         (princ "\nError or Esc pressed... ")   )   (princ) )       ; end of *error* (setq varLst  (list "CMDECHO" "CLAYER" "DIMSCALE")       oldVars (mapcar 'getvar varLst) )       ; end setq          ;    --- Error Trap --- (setvar "cmdecho" 0) (mapcar 'cllayer '("1" "2" "3" "4" "5"))  (or (getenv "cl:ratio") (setenv "cl:ratio" "122"))   (princ   (strcat "\nType "CLSET" to Change Base Variables. > C/L Ratio: "           (getenv "cl:ratio")   ) ) (while (setq c1 (entsel "\nSelect Circle for Centre-line: "))    (setq c1ent (entget (car c1)))    (if (= (cdr (assoc 0 c1ent)) "CIRCLE")      (progn        (setq c1cent (cdr (assoc 10 c1ent))              c1rad  (cdr (assoc 40 c1ent))              crat   (/ (atof (getenv "cl:ratio")) 100)        ) ; end setq        (setvar "clayer" "5")        (command "-linetype" "S" "CENTER" "")        (command "_line"                  "_non" (polar c1cent pi (* c1rad crat))                 "_non" (polar c1cent 0 (* c1rad crat))                 ""        ) ;end line        (command "_line"                 "_non" (polar c1cent (* pi 1.5) (* c1rad crat))                 "_non" (polar c1cent (/ pi 2) (* c1rad crat))                 ""        ) ; end line      )  ; end progn      (alert "\nEntity is not a Circle.")    )    ; end if    (command "-linetype" "S" "Bylayer" "") )       ; end while (*error* "") ; Thanks CAB for this  (princ "\nFunction Complete.") (princ))         ; end cl(defun cllayer (lay) (if (not (tblsearch "LAYER" lay))   (command "_.-layer" "_m" lay "_c" lay lay "") )       ; end if)         ; end cllayer(defun c:clset (/ cratio) (or (getenv "cl:ratio")(setenv "cl:ratio" "122")) (princ (strcat "\n> C/L Ratio: " (getenv "cl:ratio") "%")) (if (setq cratio (getreal (strcat "\nSpecify C/L as % of Circle Radius  : "                           )                  )     )   (setenv "cl:ratio" (rtos cratio)) )       ; end if (princ "\nBase Variables Set.") (princ))         ; end clset
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 20:10 , Processed in 0.356633 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表