乐筑天下

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

[编程交流] Alternative ALIGN routine (hel

[复制链接]

77

主题

298

帖子

232

银币

后起之秀

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

铜币
394
发表于 2022-7-5 23:06:07 | 显示全部楼层 |阅读模式
Hey guys,
 
I'm doing a task which requires a lot of 3D aligning, and am finding that the ALIGN tool is not quite accurate enough (which does seem strange - I can provide some images showing the inaccuracy if anyone would like).
 
Anyway, I have decided to try and create an alternative ALIGN routine, base on COPYBASE and PASTECLIP.
 
  1. (defun c:ali ()(prompt "\nSelect objects to align...")(setq aliss (ssget))(setq alibpt1 (getpoint "\nPick base point 1..."))(setq alidpt1 (getpoint alibpt1 "\nPick destination point 1..."))(setq alibpt2 (getpoint "\nPick base point 2..."))(setq alidpt2 (getpoint alibpt2 "\nPick destination point 2..."))(setq alibpt3 (getpoint "\nPick base point 3..."))(setq alidpt3 (getpoint alibpt3 "\nPick destination point 3..."))[color="red"][b](setq alibpt1 (trans alibpt1 1 0))(setq alidpt1 (trans alidpt1 1 0))(setq alibpt2 (trans alibpt2 1 0))(setq alidpt2 (trans alidpt2 1 0))(setq alibpt3 (trans alibpt3 1 0))(setq alidpt3 (trans alidpt3 1 0))[/b][/color](command "UCS" "3P" alibpt1 alibpt2 alibpt3)(command "copybase" alibpt1 aliss "")(command "erase" aliss "")(command "UCS" "3P" alidpt1 alidpt2 alidpt3)(command "pasteclip" "alidpt1)(princ))
 
Is my current code, I am just learning about the TRANS function and I haven't quite got my head around how it works, so I was wondering if someone could please take a look and help me understand where I am going wrong.
 
The problem with my code at the moment is that it doesn't paste the copied element(s) back to the basepoint alidpt1.  It seems that the location of these points is lost/changed when the UCS is changed. So I am trying to change the locations of the source and destination points from relevance to UCS->WCS.  Is this correct?
 
Thanks a lot for any help.
回复

使用道具 举报

77

主题

298

帖子

232

银币

后起之秀

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

铜币
394
发表于 2022-7-6 00:18:08 | 显示全部楼层
So it turned out that I needed not bother with the TRANS function, rather I had to set the UCS to world prior to the UCS>3P command.
 
  1. (defun c:ali ()(prompt "\nSelect objects to align...")(setq aliss (ssget))(command "UCS" "W")(setq alibpt1 (getpoint "\nPick base point 1..."))(setq alidpt1 (getpoint alibpt1 "\nPick destination point 1..."))(setq alibpt2 (getpoint "\nPick base point 2..."))(setq alidpt2 (getpoint alibpt2 "\nPick destination point 2..."))(setq alibpt3 (getpoint "\nPick base point 3..."))(setq alidpt3 (getpoint alibpt3 "\nPick destination point 3..."))(command "UCS" "W" "UCS" "3P" alibpt1 alibpt2 alibpt3)(command "copybase" "0,0,0" aliss "")(command "erase" aliss "")(command "UCS" "W" "UCS" "3P" alidpt1 alidpt2 alidpt3)(command "pasteclip" "0,0,0")(princ))
 
This code seems to work quite well.
 
I do welcome any feedback though.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 03:15 , Processed in 0.659464 second(s), 56 queries .

© 2020-2025 乐筑天下

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