乐筑天下

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

[编程交流] User input: Getpoint OR real a

[复制链接]

1

主题

1

帖子

0

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 06:56:52 | 显示全部楼层 |阅读模式
Hi everybody,
 
First thing I want to apologize if something that I wrote sounds strange. Im spanish and my english is not as good as it should be=P.
Im learling little by little autolisp things, mostly strugling through examples, codes, etc... many of them from this forum so I thank you a lot ^_^.
 
At this moment I'm developing a routine that breaks/trims walls in order to insert doors or windows, and, after looking for it a few days, I would like to know if there's a way to use a number that users input on the command line (in a getpoint) without getting an error.,... wich is that happends everytime =/.
 
  1. ;; HOLE-O-MaTIC 2000;;  by Arturo Blanco Ureña. 2013;; Breaks "walls" in order to insert windows or doors;; Based initialy on code from Pavel Chour http://klobouk.fsv.cvut.cz/~chour/Lisp/Chapter%206.htm(defun error1 (errmsg)  (command "_undo" "_end")  (setvar "CMDECHO" 1)  (setvar "OSMODE" osmodevar)  (setq *error* temperr)  (prompt "\nAchtung!!! Verboten!!! Error!!!\n") (princ) )(defun c:holes(/ );P1a P2a P1 P2 P3 P4 A1 A2) (setq osmodevar         (getvar 'OSMODE)temperr           *error**error*           error1         ) (if (not ancho) (setq ancho 1.50)) (setq Tancho (rtos ancho)P1 "Width") (setvar "CMDECHO" 0) (command "_undo" "_begin") (setvar "osmode" 512)  ;I'm using this structure in order to go back to the menu so I can change my mind several times. ;Don't know if there's a better way =P.  ;--- (while (= P1 "Width")  (initget 128)  (setq P1 (getpoint (strcat "\nSelect Point or [Center/Width]:")))  (cond ((numberp P1)        (setq ancho P1)                        ;trying to recognice P1 as a number but always goes on error =/                  (setq Tancho (rtos ancho))  );cond1             ((= P1 "Width")(setvar "osmode" 35)                                  (setq ancho (getdist "\nWidth of the Door/window?:"))                        (setq Tancho (rtos ancho))  );cond2   );end cond  );end while ;---  (cond ((= P1 "Center") (setvar "OSMODE" 518)                 ;If the user want to break from the center of the window.                 (setq P1a (getpoint (strcat "\nSelect center :")))                 (setvar "OSMODE" 128)                (setq P2a (getpoint P1a "\nSelect the other side of the wall:")                      A1 (angle P1a P2a)                      A2 (+ (* pi 1.5) A1)                      P1 (polar P1a A2 (* ancho 0.5))                      P3 (polar P1a A2 (* ancho -0.5))                      P2 (polar P2a A2 (* ancho 0.5))                      P4 (polar P2a A2 (* ancho -0.5))                      ) );end cond1  (T         (setvar "osmode" 128)                         ;if he/she wants to start from one side         (setq P2 (getpoint P1 "\nSelect the other side of the wall:"))         (setvar "osmode" 512)           (setq        A1 (angle P1 P2)                A2 (+ (* pi 1.5) A1)                P3 (polar P1 A2 ancho)                P4 (polar P2 A2 ancho)                P1a (polar P1 A2 (* ancho 0.5))                P2a (polar P2 A2 (* ancho 0.5))                  )   );end else);end cond  (setvar "osmode" 512) (command        "_break" P1 P3                   "_break" P2 P4                    "_line" P1 P2 "") (setq L1 (entlast)) (command        "_line" P3 P4 "") (setq L2 (entlast))  ;I add this in order to trim extra lines in the middle of the wall. (command "_trim" L1 L2 "" "B" P1a P2a "" "")  (command "_undo" "_end") (setvar "CMDECHO" 1) (setvar "OSMODE" osmodevar) (setq *error* temperr) (princ));end
 
As you see You can enter the "Width" to give it, but I would like to simply write down a number when asking for a point, recognize that is a number and use it as the value of the variant. If a point is entered, then continue normally.
 
Im a bit shy and its the first time i post a code. I have used several pieces of code from others to arrange the error handling/undo and its originally based on one tutorial from Pavel Chour, so I dont know if its right that I give permission or not to use it, or even its worth it (the trim still fails and i dont really get why ) but If anyone want to use it feel free.
 
Any tips critics and opinions are welcome also
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 09:46 , Processed in 0.727371 second(s), 54 queries .

© 2020-2025 乐筑天下

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