lamensterms 发表于 2022-7-5 23:06:07

Alternative ALIGN routine (hel

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.
 

(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..."))(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))(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.

lamensterms 发表于 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.
 

(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.
页: [1]
查看完整版本: Alternative ALIGN routine (hel