View Full Version : List line to check if radial to arc
jpaulsen
2007-07-09, 06:33 PM
Does anyone know where I can find a routine that would check if a line is radial to an arc, a circle or a polyline arc segment?
I could try writing it on my own but I know it will will take most of a day and probably several posts on the forums to do it.
rkmcswain
2007-07-09, 06:54 PM
In the meantime, you can create a dimstyle that displays angles to 8 places, then draw a line from the ARC center point to the end, then run the DIMANGULAR command between the radial line and the line in question.
CADmium
2007-07-09, 08:06 PM
Look here (http://discussion.autodesk.com/thread.jspa?threadID=328817) and use the Vlax-curve-getfirstderiv function and the scalar-product
peter
2007-07-09, 08:14 PM
Does anyone know where I can find a routine that would check if a line is radial to an arc, a circle or a polyline arc segment?
I could try writing it on my own but I know it will will take most of a day and probably several posts on the forums to do it.
(defun C:IsRadial (/ blnRadial ssItem lstClose lstCenter ssLine )
(vl-load-com)
(while (not (setq ssLine (ssget ":S:E" (list (cons 0 "LINE,Polyline,LWPolyline")))))
(princ "\nThat is not a line. Please Select Again: ")
)
(setq objLine (vlax-ename->vla-object (ssname ssLine 0))
ssCircles (ssget "x" (list (cons 0 "CIRCLE,ARC")))
)
(vlax-for objItem (vla-get-activeselectionset
(vla-get-activedocument
(vlax-get-acad-object)))
(setq lstCenter (vlax-get objItem "center")
lstClose (vlax-curve-getclosestpointto objLine lstCenter T)
)
(if (< (distance lstCenter lstClose) 0.0001)
(progn
(setq blnRadial T)
(princ "\nIs Radial: ")
)
)
)
blnRadial
)
jpaulsen
2007-07-09, 09:13 PM
Thanks for the replies guys.
R.K,
The way I check them now is to draw a new line from the intersection of the old line and arc to the center point of the arc. Then I use the DIM AN command and pick both lines. If the command return "Lines are parallel." I know the line is radial.
Thomas,
I took a look at the link discussing the first derivative function and although it appears this would work it falls under the category of "most of a day" for me to figure out how to use it. Maybe longer since I have never done anything in visual lisp
Peter,
I could not get the IsRadial routine to work. I can only select a line and not a second object.
I thought a little more about what I want this routine to do. I want to be able to pick an arc, circle, or polyline arc segment (both types of polylines) then be prompted to select a line. It would then return either "Line is Radial" or "Line is Non-Radial" to the command line. It would continue to prompt for me to select lines and check them against the arc until I hit return without selecting another line. Then it would prompt to select an arc segment, prompt for lines, etc.
I will probably take a stab at this later in the week at home.
kennet.sjoberg
2007-07-10, 01:22 AM
Here is a simple code to expand
(defun c:test (/ Line Arc )
(setq Line (entsel "Select the line" ))
(setq Arc (entsel "Select the Arc" ))
(if
(=
(rtos (angle (cdr (assoc 10 (entget (car Arc )))) (cdr (assoc 10 (entget (car Line ))))) 2 16 )
(rtos (angle (cdr (assoc 10 (entget (car Arc )))) (cdr (assoc 11 (entget (car Line ))))) 2 16 )
)
(princ "\nRadial" )
(princ "\nNot radial" )
)
(princ)
)
: ) Happy Computing !
kennet
jpaulsen
2007-07-10, 09:21 PM
Kennet,
Thanks for the code. That will be a good start for me. It works pretty good with lines, arcs and circles. However, it sometime says a radial line is Non-radial it the line gets too close to the centerpoint.
Now I need to figure out how to get it to repeat the line selection so I can check more than one line without having to reselect the arc. Then all I need to do is modify it to work with polyline segments.
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.