Jump to content

Recommended Posts

Posted

someone help me to get the start point and end point of any arc

 

 

is there any lsp routine for this?

 

thanks

 

image.thumb.png.144c1076b81dacf025bb3a5d6ad00cd4.png

 

 

test.dwg

Posted (edited)

Why a lisp routine?  Do you normally have a drawing with two or more arcs where you require such information?

Edited by ReMark
Posted

I need to learn how to get those points, I need it for another more complex routine

Posted

what I need is to touch the arc and make a mirror with axis of symmetry in the initial and final points of that arc

Posted

Extremely quick and dirty.  The DXF Reference manual is your friend...

 

(defun C:GetArc ( / 
		k MyEntSel MyEnt MyEntData MyEntType CP Radius StartAng EndAng SP EP
		)
; Select an arc, get geometry and draw radials
; KJM July 2022

(setq k 1)
(while k

	(setq MyEntSel (entsel "\nSelect an ARC..."))
	(if MyEntSel
	  (progn
	  	(setq MyEnt (car MyEntSel))
	  	(setq MyEntData (entget MyEnt))
	  	(setq MyEntType (strcase (cdr (assoc 0 MyEntData))))
	  	
	  	(if (equal MyEntType "ARC")
	  	  (progn
	  	  	(setq k nil)	; stop selection loop
	  	  )
	  	  (progn
	  	  	(prompt "\n  Selection was ")(princ MyEntType)(prompt ", try again...")(princ)
	  	  )
	  	) ; close if  
	  )
	) ; close if
	
) ; close while

; Get geometry
(setq CP (cdr (assoc 10 MyEntData)))		; Centre Point
(setq Radius (cdr (assoc 40 MyEntData)))	 
(setq StartAng (cdr (assoc 50 MyEntData)))	; Radians!
(setq EndAng (cdr (assoc 51 MyEntData)))

; Make start and end points
(setq SP (polar CP StartAng Radius))
(setq EP (polar CP EndAng Radius))

; Report
(prompt "\n  Centre = ")(princ CP)(prompt "  Radius = ")(princ Radius)
(prompt "  Start Point = ")(princ SP)(prompt "  End Point = ")(princ EP)
(princ)

; Draw something
(command ".POINT" SP)
(command ".POINT" CP)
(command ".POINT" EP)

(command ".LINE" SP CP EP "")
(princ)
)

 

Posted (edited)

There are also the curve-functions which you can feed an ename to:

VLAX-CURVE-GETSTARTPOINT

VLAX-CURVE-GETENDPOINT

(if (setq e (car (entsel)))
  (progn (setq sp (vlax-curve-getstartpoint e)) (setq ep (vlax-curve-getendpoint e)))
)

 

Edited by ronjonp
  • Like 1
Posted

Here's another, from my library:

;; Arc Endpoints  -  Lee Mac
;; Returns the endpoints of an Arc expressed in WCS

(defun LM:ArcEndpoints ( ent / cen nrm rad )
    (setq ent  (entget ent)
          nrm  (cdr (assoc 210 ent))
          cen  (cdr (assoc 010 ent))
          rad  (cdr (assoc 040 ent))
    )
    (mapcar
        (function
            (lambda ( ang )
                (trans (mapcar '+ cen (list (* rad (cos ang)) (* rad (sin ang)) 0.0)) nrm 0)
            )
        )
        (list (cdr (assoc 50 ent)) (cdr (assoc 51 ent)))
    )
)

 

  • Like 2
Posted

 now I have 2 routines that do it but separated and I don't know how to join them  :(

 

image.thumb.png.3a9c8dc4ded2e6be7abc4ec4f3055c5d.png

 

 

1.lsp 2.lsp test.dwg

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...