乐筑天下

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

[编程交流] 区域lisp帮助

[复制链接]

5

主题

24

帖子

19

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 06:26:07 | 显示全部楼层 |阅读模式
我有我们的工程师使用的lisp例程。我过去曾对其进行过调整,但现在我无法确定它失败的原因。如果有比我更熟练的人帮助我确定问题以及如何纠正,我将不胜感激。该例程应允许选择多段线,然后放置显示平方英尺的多行文字字段。在字段放置的选择点之后失败。它不会出错,但也不会显示文本。
 
  1. [font=Courier New](defun c:arl64 ()[/font]
  2. [font=Courier New](vl-load-com)[/font]
  3. [font=Courier New];;get a reference to model space[/font]
  4. [font=Courier New](setvar "textsize" 0.09375)[/font]
  5. [font=Courier New](setvar "luprec" 0)[/font]
  6. [font=Courier New](setq *model-space*[/font]
  7. [font=Courier New]       (vla-get-ModelSpace[/font]
  8. [font=Courier New]     (vla-get-ActiveDocument (vlax-get-acad-object))[/font]
  9. [font=Courier New]       )[/font]
  10. [font=Courier New])[/font]
  11. [font=Courier New];;pass this function an entity and a point[/font]
  12. [font=Courier New](defun LinkedArea (ent pt / obj objID ip width str)[/font]
  13. [font=Courier New]  ;;convert the entity to an object[/font]
  14. [font=Courier New]  (setq ar2 (car (entsel "\nSelect Area Boundary: ")))[/font]
  15. [font=Courier New]  (setq objID (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) "GetObjectIdString" (vlax-ename->vla-object ar2) :vlax-False))[/font]
  16. [font=Courier New]  (setq    ;;convert the point[/font]
  17. [font=Courier New]    ip    (vlax-3D-Point pt)[/font]
  18. [font=Courier New]    ;;set the width for the MTEXT[/font]
  19. [font=Courier New]    width 0.0[/font]
  20. [font=Courier New]  )[/font]
  21. [font=Courier New]    ;;set the string - this creates the field[/font]
  22. [font=Courier New]  (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Area \\f "%pr0%lu2%ct4%qf1 SQ. FT.">%"))[/font]
  23. [font=Courier New]    [/font]
  24. [font=Courier New]  ;;Create the MTEXT entity containing the field.[/font]
  25. [font=Courier New]  (vla-addMText *model-space* ip width str)[/font]
  26. [font=Courier New])[/font]
  27. [font=Courier New];; Set A = the entity and set B = Point for text[/font]
  28. [font=Courier New](setq a (car (entsel)) b (getpoint "\n Select Text Insertion Point: "))[/font]
  29. [font=Courier New];;Call the function[/font]
  30. [font=Courier New](linkedarea a b)[/font]
  31. [font=Courier New](princ)[/font]
  32. [font=Courier New]  )s [/font]

 
谢谢
肖恩
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 07:48:15 | 显示全部楼层
这对我很有效。嗯,我做了两个MOD。首先,始终避免使用任何LISP项作为变量。因此,我将str重命名为strg。另外,文件末尾的“s”是用来做什么的?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 18:35 , Processed in 0.467395 second(s), 56 queries .

© 2020-2025 乐筑天下

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