QuinnL Posted April 13, 2023 Posted April 13, 2023 We use an excel to determine how many lines/segements will be needed to follow a curve given a max distance away from the original curve. Can you help me finish my script. Thanks. I will attach the excel for reference. (defun C:FitLinetoCurve (/) (setq def (sqrt (-(( getreal "\nEnter in radius " ) ^2 )((abs (- (getreal "\nEnter in radius ")(getreal "\nMax dist from curve " ))) ^ 2 ) ) * 2) b3 / b4 (alert (rtos def)) (princ)$$Fit Lines to a Curve Excel.xlsx ) (princ) Quote
QuinnL Posted April 13, 2023 Author Posted April 13, 2023 I got it to work! Only issue is that I want the segment number (J8) to come up in an alert bock with --- "Segment Number: (J8)" Also could I put the segment number into the divide command. That is the next step. We would run the divide command, select the curve and type in the segment number from the code below. (defun C:LinesfromCurve (/) (setq B1 (getreal "\nRadius of Curve : ")) (setq B2 (getreal "\nMax Distance from Curve : ")) (setq B3 (getreal "\nLength of Curve : ")) (setq M1 (- B1 B2)) (setq M2 (* M1 M1)) (setq J1 (* B1 B1)) (setq J4 (- J1 M2)) (setq J5 (sqrt J4 )) (setq J6 (* J5 2)) (setq J7 (/ B3 J6)) (setq J8 (1+ (fix J7))) (setq a (getstring Segement Number:)) (alert (strcat (rtos a J8))) ;include "Segment number:" not working ; (alert (rtos J8) ) ;(alert (rtos J8) ) (princ) ) (princ) Quote
BIGAL Posted April 14, 2023 Posted April 14, 2023 Sorry but trying to understand task are you trying to add facets to a curve ? Based on maximum offset. See red line. Just pick arc etc. (alert (strcat "Number of segments " (rtos j8 2 0))) Quote
QuinnL Posted April 14, 2023 Author Posted April 14, 2023 You are right Bigal. It is used to determine sanitary manhole spacing while not getting to close to the C&G or other utilities. Your alert worked, thank you. The final step of the code would be selecting the arc for radius and length instead of typing it.(Since it is a pain to write it down every time.) Quote
QuinnL Posted April 14, 2023 Author Posted April 14, 2023 I figured it out. Here is the final code: (defun C:ArctoLines (/) (setq ent (ssget)) (setq arc (entlast)) ;object entith (setq Object (vlax-Ename->Vla-Object arc)) (setq B1 (vla-get-radius object)) (setq B3 (vla-get-arclength object)) (setq B2 (getreal "\nMax Distance from Curve : ")) (setq M1 (- B1 B2)) (setq M2 (* M1 M1)) (setq J1 (* B1 B1)) (setq J4 (- J1 M2)) (setq J5 (sqrt J4 )) (setq J6 (* J5 2)) (setq J7 (/ B3 J6)) (setq J8 (1+ (fix J7))) (alert (strcat "Number of segments: " (rtos j8 2 0))) (princ) ) (princ) Quote
QuinnL Posted April 17, 2023 Author Posted April 17, 2023 I tried it out BIGAL. Its perfect, thanks. And I will try out itoa next time mhupp. Quote
Recommended Posts
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.