Author Topic: Draw a point with especific distance  (Read 3408 times)

0 Members and 1 Guest are viewing this topic.

Fabricio28

  • Swamp Rat
  • Posts: 670
Draw a point with especific distance
« on: February 24, 2021, 02:39:20 PM »
Hi,
How are you?

I'm trying to find a lisp to create a point to 1x1 from specific point.

Anybody could help me please?

Thanks
Fabricio

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Draw a point with especific distance
« Reply #1 on: February 24, 2021, 03:55:40 PM »
One way with the use of polar function.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ p)
  2.   (or (not (zerop (getvar 'PDMODE))) (setvar 'PDMODE 3))
  3.   (if (setq p (getpoint "\nSpecify a point : "))
  4.     (entmake
  5.       (list '(0 . "POINT")
  6.             (cons 10 (polar (polar p 0.0 1.0) (* pi 0.5) 1.0))
  7.       )
  8.     )
  9.   )
  10.   (princ)
  11. )
  12.  

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Draw a point with especific distance
« Reply #2 on: February 24, 2021, 04:42:42 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / p )
  2.     (if (setq p (getpoint "\nSpecify point: "))
  3.         (entmake (list '(0 . "POINT") (cons 10 (trans (mapcar '+ p '(1 1)) 1 0))))
  4.     )
  5.     (princ)
  6. )

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Draw a point with especific distance
« Reply #3 on: February 24, 2021, 08:45:23 PM »
Perhaps a bit more so X & Y can vary, could add default values if do all the time or as per image.

Code: [Select]
(defun c:test ( / p )
(setq xy (list  (getreal "\nEnter x ") (getreal "\nEnter Y ")))
    (if (setq p (getpoint "\nSpecify point: "))
        (entmake (list '(0 . "POINT") (cons 10 (trans (mapcar '+ p xy) 1 0))))
    )
    (princ)
)

A man who never made a mistake never made anything

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #4 on: February 25, 2021, 09:22:07 AM »
One way with the use of polar function.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ p)
  2.   (or (not (zerop (getvar 'PDMODE))) (setvar 'PDMODE 3))
  3.   (if (setq p (getpoint "\nSpecify a point : "))
  4.     (entmake
  5.       (list '(0 . "POINT")
  6.             (cons 10 (polar (polar p 0.0 1.0) (* pi 0.5) 1.0))
  7.       )
  8.     )
  9.   )
  10.   (princ)
  11. )
  12.  

Thank you very much!!!!

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #5 on: February 25, 2021, 09:22:39 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / p )
  2.     (if (setq p (getpoint "\nSpecify point: "))
  3.         (entmake (list '(0 . "POINT") (cons 10 (trans (mapcar '+ p '(1 1)) 1 0))))
  4.     )
  5.     (princ)
  6. )

Mr. Lee Mac
Fantastic!! thanks!!

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #6 on: February 25, 2021, 09:25:13 AM »
Perhaps a bit more so X & Y can vary, could add default values if do all the time or as per image.

Code: [Select]
(defun c:test ( / p )
(setq xy (list  (getreal "\nEnter x ") (getreal "\nEnter Y ")))
    (if (setq p (getpoint "\nSpecify point: "))
        (entmake (list '(0 . "POINT") (cons 10 (trans (mapcar '+ p xy) 1 0))))
    )
    (princ)
)



It is very nice!!
input the distance before!! Thanks

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #7 on: February 26, 2021, 07:45:28 AM »
Hi guys

How are you?

There is not anything wrong about the code.

It is insert a point to x=1 and y=1. But in some case ins't working properly, just like the example bellow:

Anybody could help me please?

Thanks
Fabricio

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Draw a point with especific distance
« Reply #8 on: February 26, 2021, 07:53:52 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ p d g)
  2.   (or (not (zerop (getvar 'PDMODE))) (setvar 'PDMODE 3))
  3.   (and (setq p (getpoint "\nSpecify a point : "))
  4.        (setq d (getpoint "\nSpecify X direction : " p))
  5.        (setq g (angle p d))
  6.        (entmake
  7.          (list '(0 . "POINT")
  8.                (cons 10 (polar (polar p g 1.0) (+ g (* pi 0.5)) 1.0))
  9.          )
  10.        )
  11.   )
  12.   (princ)
  13. )

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #9 on: February 26, 2021, 08:02:04 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ p d g)
  2.   (or (not (zerop (getvar 'PDMODE))) (setvar 'PDMODE 3))
  3.   (and (setq p (getpoint "\nSpecify a point : "))
  4.        (setq d (getpoint "\nSpecify X direction : " p))
  5.        (setq g (angle p d))
  6.        (entmake
  7.          (list '(0 . "POINT")
  8.                (cons 10 (polar (polar p g 1.0) (+ g (* pi 0.5)) 1.0))
  9.          )
  10.        )
  11.   )
  12.   (princ)
  13. )

Thank you very much for replay

But I have many situation to insert this point. Unfortunately not a default.

maybe if I set the measure x and y (negative or positive) will be great!

Could you help me please?

Thanks


Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Draw a point with especific distance
« Reply #10 on: February 26, 2021, 08:06:07 AM »
If you have the list of coordinates then you can iterate through each point with angle and distance as I did in my last reply.

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #11 on: February 26, 2021, 08:11:39 AM »
If you have the list of coordinates then you can iterate through each point with angle and distance as I did in my last reply.

Sorry if I don't understand what you meant, but I  don't have a list of the coordinates. I'm inserting it manually.

Regards

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Draw a point with especific distance
« Reply #12 on: February 26, 2021, 08:51:22 AM »
If so then you can specify the angle in the routine as indicated in the codes below and change it to suit yours.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ p g)
  2.   (or (not (zerop (getvar 'PDMODE))) (setvar 'PDMODE 3))
  3.   (and (setq p (getpoint "\nSpecify a point : "))
  4.        (setq g (* pi 0.25)) ;; = 45 Degree
  5.        (entmake
  6.          (list '(0 . "POINT")
  7.                (cons 10 (polar (polar p g 1.0) (+ g (* pi 0.5)) 1.0))
  8.          )
  9.        )
  10.   )
  11.   (princ)
  12. )
  13.  

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #13 on: February 26, 2021, 09:14:36 AM »
If so then you can specify the angle in the routine as indicated in the codes below and change it to suit yours.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ p g)
  2.   (or (not (zerop (getvar 'PDMODE))) (setvar 'PDMODE 3))
  3.   (and (setq p (getpoint "\nSpecify a point : "))
  4.        (setq g (* pi 0.25)) ;; = 45 Degree
  5.        (entmake
  6.          (list '(0 . "POINT")
  7.                (cons 10 (polar (polar p g 1.0) (+ g (* pi 0.5)) 1.0))
  8.          )
  9.        )
  10.   )
  11.   (princ)
  12. )
  13.  

Great!! Thank very much!!

When I changed the angle worked fine!!

Regards

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Draw a point with especific distance
« Reply #14 on: February 26, 2021, 09:16:14 AM »
You're welcome anytime.

Good luck with your work.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Draw a point with especific distance
« Reply #15 on: February 27, 2021, 05:53:28 AM »
There is not anything wrong about the code.

It is insert a point to x=1 and y=1. But in some case ins't working properly, just like the example bellow

Align your UCS with the surrounding geometry, and then use my program to calculate & create a point offset by 1,1 relative to the current UCS.

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Draw a point with especific distance
« Reply #16 on: February 27, 2021, 11:13:17 PM »
Following on from Lee's suggestion this is a roughy answer, it does depend on the end picked for +- y . You may need to look at what osnap settings need to be set no real dwg to test. Tested on lines. If picking plines must exit and redo as it depends on segment picked. Enter Enter not that hard.

Code: [Select]
; point at x y offset from line by AlanH Feb 2021

(defun c:test ( / pt xy )
(command "UCS" "World")
(setq xy (list  (getreal "\nEnter x ") (getreal "\nEnter Y ")))
(while (setq pt (getpoint "\nSpecify point: Enter to exit "))
(setq pt (list (car pt)(cadr pt) 0.0))
(command "UCS" "OB" pt)
(command "UCS" "Origin" (trans (list (car pt)(cadr pt) 0.0) 0 1))
(command "POINT" xy)
(command "UCS" "World")
)
(princ)
)
[code]
A man who never made a mistake never made anything

Fabricio28

  • Swamp Rat
  • Posts: 670
Re: Draw a point with especific distance
« Reply #17 on: March 02, 2021, 12:11:52 PM »
Following on from Lee's suggestion this is a roughy answer, it does depend on the end picked for +- y . You may need to look at what osnap settings need to be set no real dwg to test. Tested on lines. If picking plines must exit and redo as it depends on segment picked. Enter Enter not that hard.

Code: [Select]
; point at x y offset from line by AlanH Feb 2021

(defun c:test ( / pt xy )
(command "UCS" "World")
(setq xy (list  (getreal "\nEnter x ") (getreal "\nEnter Y ")))
(while (setq pt (getpoint "\nSpecify point: Enter to exit "))
(setq pt (list (car pt)(cadr pt) 0.0))
(command "UCS" "OB" pt)
(command "UCS" "Origin" (trans (list (car pt)(cadr pt) 0.0) 0 1))
(command "POINT" xy)
(command "UCS" "World")
)
(princ)
)
[code]

Sorry for delay to answer you, BIGAL.

I've tested the code and worked like a charm!!!

Thank you very much all of you guys for the support. It is save me a lot of time.

Regards
Fabricio