### Author Topic: Stumped as usual  (Read 898 times)

0 Members and 1 Guest are viewing this topic.

#### Biscuits

• Swamp Rat
• Posts: 502
##### Stumped as usual
« on: December 12, 2022, 02:22:16 PM »
Trying to move an object based on the angle and distance from 2 selected points.
Could some one tell me what I'm doing wrong? I'm gettin' too old for this snit!

Code: [Select]
`(defun C:doit  ()(setq p1(getpoint))(setq p2(getpoint))(setq dis (distance p1 p2))(setq ang (angle p1 p2))(command "move" "all" "" dis ang))`

#### Lee Mac

• Seagull
• Posts: 12937
• London, England
##### Re: Stumped as usual
« Reply #1 on: December 12, 2022, 04:22:31 PM »
By default the MOVE command is expecting two points (a base point and a new point relative to such base point); for these prompts, you are supplying two numerical values (AutoCAD does not know that such numbers represent distances & angles).

Personally, I would suggest the following approach:
Code - Auto/Visual Lisp: [Select]
1. (defun c:doit ( / p1 p2 )
2.     (if
3.         (and
4.             (setq p1 (getpoint "\n1st point: "))
5.             (setq p2 (getpoint "\n2nd point: "))
6.         )
7.         (command "_.move" "_all" "" "_non" p1 "_non" p2)
8.     )
9.     (princ)
10. )

#### Biscuits

• Swamp Rat
• Posts: 502
##### Re: Stumped as usual
« Reply #2 on: December 15, 2022, 08:40:20 AM »
Once again I owe you a big thank you. Nothing like overthinking it!
Merry Christmas LM!!

#### Lee Mac

• Seagull
• Posts: 12937
• London, England
##### Re: Stumped as usual
« Reply #3 on: December 15, 2022, 02:59:57 PM »
You're welcome!
Merry Christmas to you too!

#### MSTG007

• Gator
• Posts: 2606
##### Re: Stumped as usual
« Reply #4 on: December 15, 2022, 05:20:50 PM »
how does Lee make it look so simple? lol. We sometime come up tons of lines of code, then someone gets it down to a few lines.

Merry Christmas you guys.
Civil3D 2020

#### kdub_nz

• Mesozoic keyThumper
• SuperMod
• Water Moccasin
• Posts: 2162
• class keyThumper<T>:ILazy<T>
##### Re: Stumped as usual
« Reply #5 on: December 15, 2022, 05:30:12 PM »

Practice, dedication and an inquiring mind , perhaps ?
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
Sometimes the question is more important than the answer.

#### BIGAL

• Swamp Rat
• Posts: 1459
• 40 + years of using Autocad
##### Re: Stumped as usual
« Reply #6 on: December 15, 2022, 06:20:07 PM »
I agree "how does Lee make it look so simple? " helped me many times.

Next issue is speed, 1st go for a task 35 minutes, current version 2 minutes.