乐筑天下

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

[编程交流] 零级lisp例程

[复制链接]

13

主题

46

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 08:17:31 | 显示全部楼层 |阅读模式
你好,我找到了这个:
 
http://cad-notes.com/2010/12/autolisp-exercise-using-block-and-conditional-if/
 
我根据自己的一些需要对其进行了修改,但我无法使osnap端点和交集函数在直线上工作(setvar“OSMODE”33),为什么?
 
  1. ;;Level0 put in level arrow in level 0 in different direktions.
  2. (defun c:Level0 (/ oldcmdecho oldosnap cnglobalscale labelposition levelarrowtype y x zerolevelposition y1 x1)
  3. ;;setting up before the real work is going on
  4. (setq oldcmdecho (getvar "cmdecho"))
  5. (setq oldosnap   (getvar "osmode"))
  6. (setvar "cmdecho" 0)
  7. ;;checking the scale
  8. (if (= cnglobalscale nil) ; this will check if user already has defined the drawing scale
  9. (setq cnglobalscale (getreal "\nSet Global Scale for CN Annotation <1/1>: "))
  10. )
  11. (if (= cnglobalscale nil) ; this will check if the user choose default value
  12. (setq cnglobalscale 1)
  13. )
  14. (initget 1)
  15. (while (setq labelposition (getpoint "\nPick Label Position for zerolevel: "))
  16. (setvar "OSMODE" 33)
  17. (setq levelarrowtype (getpoint "\nPick Direction of level arrow"))
  18. (setvar "OSMODE" 0)
  19. ;;setting up the zerolevel position
  20. (setq y 0)
  21. (setq x (car labelposition))
  22. (setq zerolevelposition (list x y))
  23. ;;getting direction on level arrow
  24. (setq y1 (cadr levelarrowtype))
  25. (setq x1 (car levelarrowtype))
  26. ;;Labelling the level
  27. (setq label "%%p 0.00")
  28. ;;setting conditions
  29. (cond ((and(>= y1 0) (> x1 x)) (command "_-insert" "kote3" zerolevelposition cnglobalscale cnglobalscale 0 label))  
  30.      ((and(<= y1 0) (> x1 x)) (command "_-insert" "kote4" zerolevelposition cnglobalscale cnglobalscale 0 label))
  31.      ((and(>= y1 0) (< x1 x)) (command "_-insert" "kote1" zerolevelposition cnglobalscale cnglobalscale 0 label))
  32.      ((and(<= y1 0) (< x1 x)) (command "_-insert" "kote2" zerolevelposition cnglobalscale cnglobalscale 0 label))
  33. )
  34. (setvar "osmode" oldosnap)
  35. (setvar "cmdecho" oldcmdecho)
  36. (princ)
  37. )
  38. )

 
或者保持osmode设置不变,只需在命令“insert”的调用中添加“_non”
 
  1. (while [color=blue][b](progn[/b][/color]
  2. [b][color=blue]      (setvar "OSMODE" 33)      [/color][/b]
  3. [b][color=blue]      (setq labelposition (getpoint "\nPick Label Position for zerolevel: "))[/color][/b]
  4. [b][color=blue]      (setq levelarrowtype (getpoint labelposition "\nPick Direction of level arrow")))[/color][/b]
  5. (setvar "OSMODE" 0)
  6. .....   
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 10:13:58 | 显示全部楼层
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-9 09:03 , Processed in 0.350484 second(s), 56 queries .

© 2020-2025 乐筑天下

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