乐筑天下

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

[编程交流] 工作点Lisp

[复制链接]

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-5 22:16:26 | 显示全部楼层 |阅读模式
嘿伙计们,
 
我试图制作一个lisp,用户可以在模型中选择一个点,lisp可以使用从模型中提取的坐标在纸空间中创建一个多重引线。
 
以下是我目前掌握的代码:
 
  1. (defun c:test (/ WorkingPoint Easting Northing Point)
  2. (command
  3.    "_.mspace"
  4.    );;end command
  5. (setq WorkingPoint (getpoint "\nWhere is Working Point?: "))
  6. (setq Northing (cadr WorkingPoint));;set "y" value of WorkingPoint to Northing
  7. (setq Easting (car WorkingPoint));;set "x" value of WorkingPoint to Easting
  8. (command
  9.    "_.point" WorkingPoint
  10.    );;end command
  11. (setq point (entlast));;set the workingpoint to point
  12. (command
  13.    "_.chspace" point "" ""
  14.    );;end command
  15. (setq pspaceworkingpoint (entget point))
  16. (setq mleaderinspt (list (car pspaceworkingpoint)(cadr pspaceworkingpoint)))
  17. (princ mleadinspt)
  18. );;end defun

 
每当我运行它时,对于“mleaderinspt”变量,我得到
 
  1. nilnil

 
我想做的是创建多重引线插入点,用户在其中选择原始工作点,但我很难将其转换到图纸空间。
 
请注意,我还没有添加错误检查,因为这仍处于开发阶段/概念验证。
 
非常感谢您的帮助。
 
谢谢
 
编辑:我想我已经解决了,如果可行的话,我会更新这个线程。
回复

使用道具 举报

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-5 22:31:11 | 显示全部楼层
好的,这就是我的观点:
 
  1. (defun c:test (/ WorkingPoint Easting Northing Point)
  2. (command
  3.    "_.mspace"
  4.    );;end command
  5. (setq WorkingPoint (getpoint "\nWhere is Working Point?: "))
  6. (setq Northing (cadr WorkingPoint));;set "y" value of WorkingPoint to Northing
  7. (setq Easting (car WorkingPoint));;set "x" value of WorkingPoint to Easting
  8. (command
  9.    "_.point" WorkingPoint
  10.    );;end command
  11. (setq point (entlast));;set the workingpoint to point
  12. (command
  13.    "_.chspace" point "" ""
  14.    );;end command
  15. (setq pspacepoint (entget point))
  16. (setq pspace (cdr (assoc 10 pspacepoint)))
  17. (command
  18.    "_.mleader" pspace "@10,-10" "WORKING POINT N "
  19.    )
  20. );;end defun

 
我在让多重引线输入文本时遇到问题。。。我们使用的典型格式是:
 
工作点
N: XXXXX公司
E: XXXXX公司
 
我不知道如何让它像这样显示。。。思想?我尝试使用“strcat”,但它不接受我研究中的整数。
 
也就是坐标,是这样的“2.485834611853077E+005”,我只需要它是“248583.46”,关于如何补救这个问题,有什么想法吗?
 
谢谢
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 22:52:10 | 显示全部楼层
  1. Command: (rtos (atof "2.485834611853077E+005") 2 2)
  2. "248583.46"
回复

使用道具 举报

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-5 22:56:46 | 显示全部楼层
完美的这帮我解决了一个问题
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 23:06:54 | 显示全部楼层
你使用了很多保留字点,pspsace对于变量名不是一个好主意,这可能会产生问题。
回复

使用道具 举报

11

主题

44

帖子

33

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
55
发表于 2022-7-5 23:17:38 | 显示全部楼层
我想出了一个暂时可行的方法,格式有点不合适,但用户可以通过编辑引线来修复它(可能需要命名工作点)。
 
  1. (defun c:test (/ WorkingPoint Easting Northing Point PSPACEPOINT PSPACE TEXT TEXTPROPS COORD)
  2.    (command
  3.    "_.mspace"
  4.    );;end command
  5. (setq WorkingPoint (getpoint "\nWhere is Working Point?: "))
  6. (setq Northing (rtos (cadr WorkingPoint) 2 1));;set "y" value of WorkingPoint to Northing
  7. (setq Easting (rtos (car WorkingPoint) 2 1));;set "x" value of WorkingPoint to Easting
  8. (command
  9.    "_.point" WorkingPoint
  10.    );;end command
  11. (setq point (entlast));;set the workingpoint to point
  12. (command
  13.    "_.chspace" point "" "";;this brings the workingpoint set in the modelspace to paperspace
  14.    );;end command
  15. (setq pspacepoint (entget point));;get the properties for point
  16. (setq pspace (cdr (assoc 10 pspacepoint)));;find the x&y coords and set to pspace
  17. (COMMAND
  18.    "mTEXT" PSPACE "@20,-20" "WORKING POINT" "N:"NORTHING "E:"EASTING ""
  19.    );;END COMMAND
  20.     (setq text (entlast));;set mtext to variable text
  21.     (setq textprops (entget text));;get the properties from text
  22.     (setq coord (cdr (assoc 1 textprops)));;find the string properties and set to coord
  23.     (command
  24.    "_.mleader" pspace "@10,-10" coord
  25.    "_.erase" point text ""
  26.    );;END COMMAND
  27. );;end defun
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 06:32 , Processed in 0.433078 second(s), 64 queries .

© 2020-2025 乐筑天下

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