Jump to content

Script to determine lines needed to complete a curve.


Recommended Posts

Posted

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)

Posted

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)

Posted

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.

 

image.thumb.png.daf93a7bddd8513e644c885d5bb17556.png

 

 

(alert (strcat "Number of segments " (rtos j8 2 0)))

 

Posted

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.) 

 

 

 

 

Posted

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)
  
 

Posted

I tried it out BIGAL. Its perfect, thanks.

 

And I will try out itoa next time mhupp. 

 

 

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...