乐筑天下

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

[编程交流] Lisp: Copy in the space and pa

[复制链接]

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 17:04:35 | 显示全部楼层 |阅读模式
Im working in my second lisp. Its a very simple series of commands: with some objects rotate in a random space, the idea is to put the ucs with a face of the objects, copy them, return in the world ucs and paste the original objets oriented in the world ucs.
 
My first lisp was this:
 
  1. (DEFUN c:CW ( / P1 P2 P3 ) (SETQ P1 (GETPOINT "\nSelect first UCS point")) (SETQ P2 (GETPOINT "\nSelect second UCS point")) (SETQ P3 (GETPOINT "\nSelect third UCS point")) ;click the 3 ucs points                 (command "_ucs" "_3p" "_non" P1 "_non" P2 "_non" P3) ; rotate the ucs in the objects plane        (command "_select" pause ) ; select objects to copy                 (command "_copyclip" "_p" "" )        (command "_ucs" "_w") ; return in world ucs                 (command "_pasteclip" ) ; paste objects in the world ucs  (PRINC) )
 
but the paste objets is not close to the insert point of the paste command. To solve it i was thinking to use the "copybase" command in this way:
 
  1. (DEFUN c:CW1 ( / P1 P2 P3 P4 P5 ) (SETQ P1 (GETPOINT "\nSelect first UCS point")) (SETQ P2 (GETPOINT "\nSelect second UCS point")) (SETQ P3 (GETPOINT "\nSelect third UCS point")) ;click the 3 ucs points (SETQ P4 (GETPOINT "\nSelect base point of the copy objects")) ;click the base point                  (command "_ucs" "_3p" "_non" P1 "_non" P2 "_non" P3) ; rotate the ucs in the objects plane        (command "_select" pause ) ; select objects to copy                 (command "_copybase" "_non" P4 "_p" "" )        (command "_ucs" "_w") ; return in world ucs  (SETQ P5 (GETPOINT "\nSelect base point to paste the objects")) ;click the base point                 (command "_pasteclip" "_non" P5 ) ; paste objects in the world ucs  (PRINC) )
 
but when i paste the objects are invisible and i paste them in a custom position in the layer (also if its asking me the base point in the copybase command.
 
Im a rookie, i must forgive something, so i will be glad for any help.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:28:57 | 显示全部楼层
A coordinate transformation is required:
  1. (defun c:cw2 ( / bpt pt1 pt2 pt3 sel )   (and (setq sel (ssget))        (setq pt1 (getpoint "\nSpecify 1st UCS point: "))        (setq pt2 (getpoint "\nSpecify 2nd UCS point: "))        (setq pt3 (getpoint "\nSpecify 3rd UCS point: "))        (setq bpt (getpoint "\nSpecify basepoint: "))        (setq bpt (trans bpt 1 0))        (command            "_.ucs" "_3p" "_non" pt1 "_non" pt2 "_non" pt3            "_.copybase" "_non" (trans bpt 0 1) sel ""            "_.ucs" "_w"            "_.pasteclip" "\"        )   )   (princ))
回复

使用道具 举报

3

主题

9

帖子

6

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 18:03:42 | 显示全部楼层
 
thanks a lot, i will study the transormation.
If you could also answer me about some doubts about your lisp i willa appreciate a lot:
 
1 - at the beginning you put an (and) with all inside. Why? The meaning?
2 - I was repeating a (command) with all my autocad commads, and you only put one for all. With only one (command), works better or is it only a way to do it more compact?
3 - The pasteclip command is with a "\\" that i dont understand. Also because i dont see a getpoint to insert the paste. What will it happen if i will put another command below the pasteclip?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 18:08:30 | 显示全部楼层
 
Please see the explanation in this post.
 
 
There may be a negligible improvement to performance by reducing the number of command expressions, but ultimately, only one command expression is required and so there is no need for more.
 
 
The backslash (note that a single backslash is represented by "\\" in AutoLISP, as "\" is an Escape Character) is the macro operator for "pause for user input"; you can alternatively use the 'pause' symbol, but this is not a protected symbol and thus has the potential to be redefined.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 09:08 , Processed in 0.500746 second(s), 60 queries .

© 2020-2025 乐筑天下

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