SET POINT UCS COORDINATE

SET POINT UCS COORDINATE

Anonymous
Not applicable
2,405 Views
14 Replies
Message 1 of 15

SET POINT UCS COORDINATE

Anonymous
Not applicable

Hi all Please Help me write Lisp

I want to click a point to enter the UCS value.
Example : Original Coordinate = X = 30.5678 Y = 12.0456 Z = 0.0000
I want to set a new = X = 0.0000 Y = 5000.0000 Z = 0.0000
 
Thanks
 Untitled-Project.gif
0 Likes
Accepted solutions (1)
2,406 Views
14 Replies
Replies (14)
Message 2 of 15

marko_ribar
Advisor
Advisor
(defun c:oldcoord2newcoord ( / ptw ow vw )
  (setq ptw (trans (getpoint "\nClick on point you want to set coordinates of or specify old coordinates : ") 1 0))
  (setq ow (trans '(0.0 0.0 0.0) 1 0))
  (setq vw (mapcar '- ptw ow))
  (setq ptw (trans (getpoint "\nSpecify new coordinates you wish for clicked point : ") 1 0))
  (vl-cmdf "_.UCS" "_W")
  (vl-cmdf "_.UCS" "_M" "_non" (mapcar '- vw ptw))
  (princ)
)

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 15

Anonymous
Not applicable

@marko_ribar 

 

The result is not correct.

0 Likes
Message 4 of 15

marko_ribar
Advisor
Advisor

@Anonymous wrote:

@marko_ribar 

 

The result is not correct.


The result is correct... I checked it on my AutoCAD...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 5 of 15

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

The result is not correct.


That is never enough information.  What is not correct about it?

 

But in the meantime....  @marko_ribar, My UCS command does not show any _M option.  [I'm in Acad2019, but Help for 2021 doesn't describe one, either.]  What is intended?

Kent Cooper, AIA
0 Likes
Message 6 of 15

marko_ribar
Advisor
Advisor

"M" - UCS "Move" source origin to destination new point origin...

Of course I assumed that OP's initial UCS was actually WCS... I haven't considered in my code 3D orientation - random UCS...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 7 of 15

Anonymous
Not applicable

@marko_ribar 

Hi friend 

I tried it
When I type 500 but the result is X = -326.6986 Y = -364.4778 Z = 0.000
It should be X = 0.000 Y = 500.000 Z = 0.000

 

Untitled-Project.gif

0 Likes
Message 8 of 15

Sea-Haven
Mentor
Mentor

When asked for the new co-ords you enter 0,5000,0 and it works for me.

 

Marko maybe ask X Y Z rather than a point. 

 

For me using multi getvals.lsp

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "New values " "X  " 8 7 "0.0" "Y  " 8 7 "0.0" "Z  " 8 7 "0.0" )))
(setq pt (list (atof (nth 0 ans))(atof (nth 1 ans ))(atof (nth 2 ans))))

 

(setq ptw (trans pt 1 0))

screenshot210.png

 

Message 9 of 15

Anonymous
Not applicable

@Sea-Haven 

@marko_ribar 

All right!
Can I continue to the next point?
And I always want the X&Z value to be 0

Thank you

0 Likes
Message 10 of 15

lena.talkhina
Alumni
Alumni

Welcome to Autodesk Community @Anonymous !

 

Great to see you here on LISP forum.

Don't hesitate to accept a solution if find one.

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.



Лена Талхина/Lena Talkhina
Менеджер Сообщества - Русский/Community Manager - Russian

0 Likes
Message 11 of 15

marko_ribar
Advisor
Advisor

@Anonymous wrote:

@Sea-Haven 

@marko_ribar 

All right!
Can I continue to the next point?
And I always want the X&Z value to be 0

Thank you


I don't know what you are after, but as Alan explained you have to specify all 3 coordinates separated with "," when asked (commas - without quotes)... If you want to continue changing UCS from previous settings and continously set new coordinates, bear in mind that old ones will change... Here is my code slightly modified for working in random UCS, so with this code you may continue with setting coordinates all until you set last point you pick...

 

 

(defun c:oldcoord2newcoord ( / pt v )
  (setq pt (getpoint "\nClick on point you want to set coordinates of or specify old coordinates : "))
  (setq v pt)
  (setq pt (getpoint "\nSpecify new coordinates you wish for clicked point : "))
  (vl-cmdf "_.UCS" "_non" (mapcar '- v pt) "")
  (princ)
)

 

Hope that now is all fine and satisfies your requests... I changed "M" option as also with my AutoCAD it's not specifed as Kent noticed (it was coded from my experience of working with UCS, not from actuall options provided within command)...

Still I don't quite know why do you need this LISP (if you specify new coordinates, you can as well type them in text you create directly without changing any setting of UCS and this mod. covers only last setting of point coords - it's only better because of general approach that assumes that user works in some random UCS instead of initial AutoCAD default WCS)...

I don't know what else you requested more, I suppose this was correct answer so that you can mark it as soultion...

Am I wrong and missing something more important? You can either way alter my solution to your specific needs to input only single coordinate, but then it won't cover situations that may be more general (all 3 specifications of point data)... We need more info about things explaining what exactly you want to achieve. Then I suppose your input will make some sense - specifications of just Y coordinate... Anyway I leave both explanations and altering provided solution to you...

Stay well and take care.

Regards, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 12 of 15

Sea-Haven
Mentor
Mentor

Marko sometimes in CIVIL work will change the ucs from like 67854322.123, 123456.789 to 0,0 and rotate so just makes a bit easier to draft doing PLAN after setting UCS. Makes the text square to orientation etc but the real world co-ords are still there if required. Often for multiple layouts multi ucs to reorient plan view angle.

 

What is interesting not asking for second point or rotation as well.

0 Likes
Message 13 of 15

Anonymous
Not applicable

@marko_ribar 

Hi Friend

 

(defun c:oldcoord2newcoord ( / pt v )
  (setq pt (getpoint "\nClick on point you want to set coordinates of or specify old coordinates : "))
  (setq v pt)
  (setq pt (getpoint "\nSpecify new coordinates you wish for clicked point : "))
  (vl-cmdf "_.UCS" "_non" (mapcar '- v pt) "")
  (princ)
)

When I enter the value 0,5000,0
And I just want to enter the value 5000 only

 

Sorry, I'm not good at English

0 Likes
Message 14 of 15

marko_ribar
Advisor
Advisor
Accepted solution

I don't know what do you need this for, but here you are...

 

(defun c:oldcoord2newcoord ( / pt v Ycoord )
  (setq pt (getpoint "\nClick on point you want to set coordinates of or specify old coordinates : "))
  (setq v pt)
  (setq Ycoord (getreal "\nSpecify Y coordinate ( X = 0.0 ; Z = 0.0 ) : "))
  (setq pt (list 0.0 Ycoord 0.0))
  (vl-cmdf "_.UCS" "_non" (mapcar '- v pt) "")
  (princ)
)

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 15 of 15

Anonymous
Not applicable

@marko_ribar 

Like this

Thank you

0 Likes