Jump to content

AutoLISP Command to limit arc length along x-axis


geo1595

Recommended Posts

attachment.php?attachmentid=55794&cid=1&stc=1

The red line is the part to be removed and the yellow arc length needs to be restricted by the BLOWOFFcm where the radius of the arc is sag.

Also, the two white lines that are present won't be in the final script.

I have posted my script below.

;; Sets the initiating command to "TEST"

(defun C:TEST()

;; Sets the pre-defined values for blow-off

(setq d 0.0211)
(setq F 0.63)
(setq T 1878)

;; Sets the variables for blow-off

(setq Vw (getreal "\n Enter the Windspeed (m/s):"))
(setq L (getreal "\n Enter the Span-length (m):"))

;; Calculates the Blow-off in (m)

(setq multiply1 (* (* Vw Vw) (* L L)))
(setq multiply2 (* d F))
(setq BLOWOFFm1 (* multiply1 multiply2))
(setq BLOWOFFm (/ BLOWOFFm1 (* 8 T)))

;; Sets pre-defined values for sag

(setq V 7.159)
(setq t 1878)

;; Sets the variables for sag

(setq S (getreal "\n Enter the height at the start of the span (m):"))
(setq E (getreal "\n Enter the height at the end of the span (m):"))
(setq As L)

;; Calculates position of low point in span

(setq P (- (/ As 2) (* t (/ (- E S) (* V As)))))

;; Calculates the wire sag (m)

(setq sag1 (/ (* V (EXPT P 2.0)) (* 2 t)))

;; Converts wire sag into (cm)

(setq sag (* sag1 100))

;; Converts BLOWOFFm onto (cm)

(setq BLOWOFFcm (* BLOWOFFm 100))

;; Asks the user to select the original wire location

(setq originalwire (getpoint "\n Select the original wire location:"))

;; Sets temporary points for blow-off

(setq temp1 (polar originalwire 4.7123889803846898576939650749193 sag))

;; Draws clearance circle for originalwire

(command "_CIRCLE" originalwire (/ d 2))

;; Creates points for arc based on blowoff and sag

(setq arcpointmiddle (polar temp1 1.5707963267948966192313216916398 BLOWOFFcm))
(setq arcpointright (polar arcpointmiddle 0.0 BLOWOFFcm))
(setq arcpointleft (polar arcpointmiddle 3.1415926535897932384626433832795 BLOWOFFcm))

;; Linetype load

(defun ltype_set (ltname)
(if (not (tblsearch "LTYPE" ltname)) ;; Check to see if the linetype exists
(if (findfile "acad.lin")
(command "._LINETYPE" "._LOAD" ltname "acad.lin" "") ;; Load the linetype if it is found
(setq ltname "Continuous") ;; If not, set the linetype to Continuous
)
)
)

;; Creates a new layer for the clearnace to be placed on after checking if the layer already exists

(defun layer_set (lyr col ltname)
(if (tblsearch "LAYER" lyr) ;; Check to see if the layer exists
(command "._LAYER" "_THAW" lyr "_UNLOCK" lyr "_ON" lyr "_SET" lyr "") ;; If layer exists, set it current

;; If the layer doesn't exist, make this layer

(if (tblsearch "LTYPE" ltname) ;; If linetype doesn't exist
(command "._LAYER" "_MAKE" lyr "_COLOUR" col lyr "_LT" ltname lyr "")
(command "._LAYER" "_MAKE" lyr "_COLOUR" col lyr "_LT" "Continuous" lyr "")
)
)
)

;; Draws arc from arcpointright to arcpointleft through arcpointmiddle on the new layer

(layer_set "Continuous" "50" "DASHDOT")
(command "._CIRCLE" originalwire sag)
;(command "._ARC" arcpointleft arcpointmiddle arcpointright)

;; Reset layer back to "0"

(layer_set "0" "7" "Continuous")

;; Draws clearance circles for left, right and middle arcpoints

(command "_CIRCLE" temp1 (/ d 2))
(command "_CIRCLE" arcpointleft (/ d 2))
(command "_CIRCLE" arcpointright (/ d 2))

;; Draws lines for trim

(setq line1 (polar arcpointleft 4.7123889803846898576939650749193 BLOWOFFcm))
(command "._LINE" arcpointleft line1 "")
(setq line2 (polar arcpointright 4.7123889803846898576939650749193 BLOWOFFcm))
(command "._LINE" arcpointright line2 "")

;; Creates a text box containing the BLOWOFFcm value

(setq text3 (getpoint "\n Pick the first point for the dimension box:"))
(setq text4 (getpoint "\n Pick the second point for the dimension box:"))
(command "_.MTEXT" text3 text4 "Blow-off (cm) =" BLOWOFFcm "")

;; Creates a text box containing the Sag value

(setq text5 (getpoint "\n Pick the first point for the dimension box:"))
(setq text6 (getpoint "\n Pick the second point for the dimension box:"))
(command "_.MTEXT" text5 text6 "Sag (cm) =" sag "")

;; Trims the excess circle

(command "._TRIM" "")

(princ)
)

 

Also, how can I create an additional point at each end of the yellow arc?

 

Thanks for any help :)

Untitled.png

Link to comment
Share on other sites

Tried you lisp, but still not sure what you're trying to do. Rather than drawing a circle and trimming it why not just draw an arc? Since sag²-BLOWOFFcm²=dy² and BLOWOFFcm/sag=cosine of ½ arc angle it should be simple enough to draw the arc and endpoints.

Link to comment
Share on other sites

I had tried creating an arc using two points but had the problem of it not having the sag as a radius. (I have removed it from the code as it started breaking it and I though about using a circle and trimming it)

;; Draws arc from arcpointright to arcpointleft through arcpointmiddle on the new layer

(layer_set "Continuous" "50" "DASHDOT")
(command "._CIRCLE" originalwire sag)
;(command "._ARC" arcpointleft arcpointmiddle arcpointright)

 

I'm not really sure how I would implement your suggestion as your equations are confusing me a bit :cry:

Link to comment
Share on other sites

Your arcpointleft, arcpointmiddle, and arcpointright points do not make an arc. Try using

 (command "._Line" arcpointleft arcpointmiddle arcpointright "")

to place a line between those points in the drawing to see they make a straight line. You cannot draw an arc with three points that produce a straight line. None of them are one the circle either. Arc command will work if you calculate those points correctly. Since BLOWOFFcm is the dx for the endpoints and I showed how to get the dy for the endpoints above all you have to do is subtract the sag value fro the x value of originalwire to get the arcpointmiddle point.

Link to comment
Share on other sites

That worked a treat thanks tombu!

 

How would I get the bottom arc to tangent the 3 circles? I could set a point at the bottom of the middle circle but what about the two at the sides?

 

attachment.php?attachmentid=55801&cid=1&stc=1

 

I did it in the picture by:

;; Draws arc from arcpointright to arcpointleft through arcpointmiddle on the new layer

(layer_set "Continuous" "50" "DASHED")
(command "._ARC" arcpointleft arcpointmiddle arcpointright "")

;; Sets another set of points for the clearance arc

(setq clearancearcmiddle (polar arcpointmiddle 4.7123889803846898576939650749193 66))
(setq clearancearcleft (polar arcpointleft 4.7123889803846898576939650749193 66))
(setq clearancearcright (polar arcpointright 4.7123889803846898576939650749193 66))



;; Draws clearance arc

(command "._ARC" clearancearcleft clearancearcmiddle clearancearcright)

Capture.PNG

Link to comment
Share on other sites

Assuming those three circles have the same radius just offset the first arc by that amount. I would entmake another arc using the entget entity list data from the first with the modified radius. Take a look at the DXF group codes for an arc entity. As I remember all you need to entmake the arc are the Center point, Radius, Start angle, and End angle.

Link to comment
Share on other sites

I can't get the arc to work correctly, i can do it by using the circle command but I don't need the excess circle beyond the 3 smaller circles.

I would like the arc to be tangent to the 3 circles at the red areas highlighted but also end at the two circles on the end.

 

This is what I have managed to get but using the circle command:

#

(command "._CIRCLE"     originalwire (+ sag 66))

 

This is the circle I get:

attachment.php?attachmentid=55837&cid=1&stc=1

Untitled.png

Link to comment
Share on other sites

I managed to get the arc by creating points at the circle tangents:

 

;; Sets temporary points for the clearance arc

(setq edge1 (polar arcpointleft 3.979350694547071435386014952154 66))
(setq edge2 (polar arcpointright 5.4454272662223082800019151976845 66))

;; Draws clearance arc

(command "._ARC" edge1 clearancearcmiddle edge2)

 

attachment.php?attachmentid=55838&cid=1&stc=1

 

Thank you for all of your help tombu and BIGAL, you have helped me out loads!

Untitled.png

Link to comment
Share on other sites

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