Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need Lisp to interpolate and label levels on arc

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
Anonymous
1368 Views, 12 Replies

Need Lisp to interpolate and label levels on arc

I need a lisp to interpolate and label elevation on arc wherever clicked when start point and end point levels are given.

I have attached a sample drawing.

Thanks,

12 REPLIES 12
Message 2 of 13
CADaSchtroumpf
in reply to: Anonymous

Quicly try this !

(defun C:Test ( / js ename obj lg js_start js_end z_start z_end pt lg_seg)
  (princ "\nSelect an arc.")
  (while (null (setq js (ssget "_+.:E:S" '((0 . "ARC")))))
    (princ "\nEmpty, or isn't an arc!")
  )
  (setq
    ename (ssname js 0)
    obj (vlax-ename->vla-object ename)
    lg (vlax-curve-GetDistAtPoint obj (vlax-curve-GetEndPoint obj))
  )
  (cond
    ((and
      (setq js_start (ssget "_C" (mapcar '- (vlax-curve-GetStartPoint obj) '(1.0 1.0 0.0)) (mapcar '+ (vlax-curve-GetStartPoint obj) '(1.0 1.0 0.0)) '((0 . "POINT"))))
      (setq js_end (ssget "_C" (mapcar '- (vlax-curve-GetEndPoint obj) '(1.0 1.0 0.0)) (mapcar '+ (vlax-curve-GetEndPoint obj) '(1.0 1.0 0.0)) '((0 . "POINT"))))
     )
      (setq
        z_start (cadddr (assoc 10 (entget (ssname js_start 0))))
        z_end (cadddr (assoc 10 (entget (ssname js_end 0))))
      )
      (while (setq pt (getpoint "\nGive a point on the arc: "))
        (cond
          ((setq lg_seg (vlax-curve-GetDistAtPoint obj (vlax-curve-getClosestPointTo obj pt T)))
            (print (+ (* (/ (- z_end z_start) lg) lg_seg) z_start))
            (command "_mleader" (vlax-curve-getClosestPointTo obj pt T) pause (rtos (+ (* (/ (- z_end z_start) lg) lg_seg) z_start) 2 3))
          )
          (T (princ "\nPoint is out of the arc"))
        )
      )
    )
  )
  (prin1)
)

 

Message 3 of 13
braudpat
in reply to: CADaSchtroumpf

Hello

Sorry but I don't know how to use this routine !?

I select an Arc and then <Enter> and then nothing ... Not possible to CLIC somewhere outside for the Label ...


THE HEALTH, Regards, Patrice

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 4 of 13
CADaSchtroumpf
in reply to: Anonymous

As in his example drawing, there must be a point at the ends of the arc placed in 3D, it is the Z of these points that are used ...

Message 5 of 13
braudpat
in reply to: CADaSchtroumpf

Hello

THANKS !

THE HEALTH, Regards, Patrice
Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 6 of 13
hak_vz
in reply to: Anonymous

Try  this.

 

 

(defun c:interpArcElevations ( / *error* e eo oldosmode doc activeSpace sp ep cp co h1 h2 H pt del_p arcLength)
(defun *error* ( msg )
	(if (not (member msg '("Function cancelled" "quit / exit abort")))
		(princ (strcat "\nError: " msg))
	)
	(setvar 'osmode oldosmode)
	(setvar 'cmdecho 1)
	(vla-endundomark doc)
	(princ)
)
(setq e (car (entsel "\nSelect arc >")))
(cond ((and e)

(setq oldosmode (getvar 'osmode))
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vla-endundomark doc)
(vla-startundomark doc)
(setq activeSpace (vlax-get-property doc(if (= 1 (getvar 'cvport)) 'paperspace 'modelspace )))
(setq eo (vlax-ename->vla-object e ))
(setq sp (vlax-get eo 'Startpoint))
(setq ep (vlax-get eo 'Endpoint))
(setq cp (vlax-get eo 'Center))
(setq co (vla-addCircle activeSpace (vlax-3d-point sp) 1))
(setq h1 (getreal "\nElevation at marked point >"))
(setq arcLength (vlax-get eo 'ArcLength))
(vla-delete co)
(setq co (vla-AddCircle activeSpace (vlax-3d-point ep) 1))
(setq h2 (getreal "\nElevation at marked point >"))
(setq H (abs(- h2 h1)))
(vla-delete co)
(setvar 'osmode 512)
(setvar 'cmdecho 0)
	(while (and(setq pt (getpoint "\nSelect interpolation point on arc element >")))
		(cond
			((and (<= (abs(- (distance pt cp) (vlax-get eo 'Radius))) 1e-10)(inters cp pt sp ep))
				(setq del_p (* (/ (vlax-curve-getDistAtPoint eo pt) arcLength) H))
				(if (< h2 h1) (setq del_p (* -1 del_p)))
				(setq co (vla-addCircle activeSpace (vlax-3d-point pt) 0.5))
				
				(command "text" pt 1 0 (rtos (+ h1 del_P) 2 2) "")
		)
		)
	)
	(setvar 'osmode oldosmode)
	(setvar 'cmdecho 1)
	(vla-endundomark doc)
))
(princ)
)

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 7 of 13
Anonymous
in reply to: Anonymous

Thanks, Works perfectly.

Message 8 of 13
Anonymous
in reply to: hak_vz

hak_vz 

 

your lisp is great as well.

 

Thanks

Message 9 of 13
Kent1Cooper
in reply to: Anonymous

You are really talking about what shows as an Arc in plan view, but representing a Helix.  The example Arc has its ends at the same Z coordinate [0], not at the numbers indicated.  But there are an infinite number of Arcs that can have their endpoints at the drawn XY locations and at the Z elevations indicated [picture any one of them, and you can spin it around the endpoints like a jump-rope].  If it's really an Arc with endpoints at different elevations, distances along it will not be proportional to distances in the Z direction.  For example, if its midpoint is at an elevation halfway between those of its endpoints, a point 1/4 of the way along it will not be at an elevation 1/4 of the way between the endpoint elevations.  That kind of proportionality would happen only with a Helix.  Is that what you're trying to represent?

Kent Cooper, AIA
Message 10 of 13
Anonymous
in reply to: Anonymous

Yes, it is actually a helix and looks like an arc in the plan,the solution should be cosidering the length of a helix and not the arc , Not sure if both the elvation output will differ. This is required for Kerb setout for roads.

 

Thanks.

Message 11 of 13
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

....  If it's really an Arc with endpoints at different elevations, distances along it will not be proportional to distances in the Z direction.  For example, if its midpoint is at an elevation halfway between those of its endpoints, a point 1/4 of the way along it will not be at an elevation 1/4 of the way between the endpoint elevations.  ....


To illustrate:

The green is an actual Arc with its endpoints at different elevations, which of course looks elliptical in this WCS plan view.  The midpoint is halfway between the elevations of the ends; the red Points are quarter points along the length of the Arc.  Note that the 1st & 3rd quarter-points are not at elevations halfway between the end- and mid-point elevations [which would be ±0.5].

ArcTilt1.PNG

And to take it to more of an extreme:

ArcTilt2.PNG

Note that the quarter-points are at elevations farther from that of the mid-point than the end-points are!  The Arc goes upward from the high end before it drops, and goes below the low end before it gets there.

Kent Cooper, AIA
Message 12 of 13
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
....  The Arc goes upward from the high end before it drops, and goes below the low end before it gets there.

[That is, it goes upward in the up-off-the-page Z-axis direction as well as in the plan-view Y direction in this particular orientation of things.]

Kent Cooper, AIA
Message 13 of 13
Anonymous
in reply to: Kent1Cooper

Yep, This is not proportional to the distance . In road works a calculation of the plan distance is quite okay for setting out. and that is what our colleagues are practising. Is forming the lisp for this type of arc will be bit tricky?

By the way thanks for your knowledgeable information. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report