Sambuddy Posted December 9, 2019 Posted December 9, 2019 I am trying to make this work but sometimes it works and sometimes does not. Please bare in mind that I just learned POLAR function and it may not the efficient way. The radius through fillet I am choosing sometimes works but sometimes comes up with an error that radius is too big. Is there another way to deal with drawing this or could there be a way to add arc without fillet? could someone also please explain the ssget function and how I can select any object i create and store under a variable? say, in this case I want to select all my lines: how would I do it? Please describe with some details so I can learn. Thanks ;; PROGRAM TO DRAW TOWER ANGLE WITH 60 DEG. ANGLE ;; (defun c:TANG (/ stpt totang thkang brkang r1 r2 si1 si2 S1 rad1) ; General questions (setq stpt (getpoint "\n Pick a point:") totang (getreal "\n Enter Angle Size:") thkang (getreal "\n Enter Angle Web Thickness:") brkang (getreal "\n Enter Break Distance:") ) ; calculate arc (setq r1 (/ thkang 2) r2 (* thkang 1) ) ; calculate polar coordinate ;(polar refpoint angle distance) (setq si1 (sin (angtof "7.5"))) (setq si2 (sin (angtof "82.5"))) (setq S1 (* (/ thkang si2) si1)) (setq p1 stpt p2 (polar p1 (angtof "90") brkang) p3 (polar p2 (angtof "105") (- totang brkang)) p4 (polar p3 (angtof "195") thkang) p5 (polar p4 (angtof "285") (- (- totang brkang) S1)) p6 (polar p5 (angtof "270") (- (- brkang thkang) S1)) p7 (polar p6 (angtof "180") (- (- brkang thkang) S1)) p8 (polar p7 (angtof "165") (- (- totang brkang) S1)) p9 (polar p8 (angtof "255") thkang) p10 (polar p9 (angtof "345") (- totang brkang)) p11 (polar p10 (angtof "0") brkang) ) ; to draw the lines (setq rad1 (* thkang 0.75)) (command "line" p1 p2 "") (command "line" p2 p3 "") (command "line" p3 p4 "") (command "line" p4 p5 "") (command "line" p5 p6 "") (command "line" p6 p7 "") (command "line" p7 p8 "") (command "line" p8 p9 "") (command "line" p9 p10"") (command "line" p10 p11 "") (command "fillet" "_R" r1) (command "fillet" p3 p4) (command "fillet" p8 p7) (command "fillet" "_R" rad1) (command "fillet" p6 p5) (princ) ) ;end defun Quote
hanhphuc Posted December 11, 2019 Posted December 11, 2019 (edited) On 12/10/2019 at 5:47 AM, Sambuddy said: I am trying to make this work but sometimes it works and sometimes does not. Please bare in mind that I just learned POLAR function and it may not the efficient way. > when command drawing line, make sure "_non" (setvar 'osmode 0) The radius through fillet I am choosing sometimes works but sometimes comes up with an error that radius is too big. > you need to calculate filletrad before command fillet Is there another way to deal with drawing this or could there be a way to add arc without fillet? > entmake lwpolyline - populate point list with bulge value: (list (cons 10 point ) (cons 42 bulge )) ,or vla-setbulge could someone also please explain the ssget function and how I can select any object i create and store under a variable? > LM ssget say, in this case I want to select all my lines: how would I do it? > (setq ss (ssget '((0 . "LINE")))) Please describe with some details so I can learn. Thanks This example using entmake method, this code shows only fillet with r1. using vla-setbulge easier for you try to test bulge value just comment or uncomment (semi-colon) last few lines of code to see the changes ; (setq ob (vlax-ename->vla-object en)) ; (foreach x '( 3 8 ) (vla-setbulge ob x (tan (* pi 0.125)))) (defun c:TANG (/ stpt totang thkang brkang r1 l s1 tan d1 d2 d3 c p l en ob ) (and (setq stpt (getpoint "\n Pick a point: ")) (setq *param* (mapcar 'UREAL '(6 6 6) '("" "" "") '("\n Enter Angle Size: " "\n Enter Break Distance: " "\n Enter Angle Web Thickness: " ) (cond (*param*) ('(100. 10. 5.)) ) ) ) (apply '> *param*) ;; varify input distance ;ie web thickness must not be greater than (mapcar 'set '(totang brkang thkang) *param*) ; set variables (setq r1 (/ thkang 2) dtr '((x) (* (/ x 180. ) pi)) l (mapcar ''((x) (sin (dtr x))) '(7.5 82.5)) ; S1 (* (/ thkang (cadr l)) (car l)) tan '((x) (/ (sin x) (cos x))) ; tan function d1 (- totang brkang) d2 (- brkang thkang) c (/ r1 (cos (* pi 0.25))) ; chord length d3 (list 0.0 brkang d1 r1 c (- d1 s1 r1) (- d2 s1)) ; distance list in sequence p (trans stpt 1 0) ; converts UCS point to WCS l (mapcar ''((a b /) (cons 10 (setq p (polar p (dtr a) b))) ) '(0 90 105 195 240 285 270 180 165 210 255 345 0) (apply 'append (list d3 (reverse d3))) ) ; loop for (polar p angle distance) ,output as list without setting variables p1,p2...p11 en (entmakex (vl-list* '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(70 . 1) (cons 90 (length l)) l ) ) ) (setq ob (vlax-ename->vla-object en)) (foreach x '(3 8) (vla-setbulge ob x (tan (* pi 0.125)))) ) (princ) ) ;;;---------------------------------------------------- ;; courtesy of the author's of "Inside AutoLisp" ;; for rel. 10 published by New Riders Publications ;;;--------------------------------------------------- (defun UREAL (bit kwd msg def / inp) (if def (setq msg (strcat "\n" msg " <" (rtos def 2) "> : ") bit (* 2 (fix (/ bit 2))) ) (setq msg (strcat "\n" msg " : ")) ) (initget bit kwd) (setq inp (getreal msg)) (if inp inp def) ) For fillet rad1 (R), try it yourself - recalculate polar angle as well as bulge value 1. find intersection point to get TL (from leg till red triangle) 2. find Td = 2r x sin (A/2) , A=120° , since it's a 3x60° triangle, i.e: Td = chord length (both is identical) 3. next polar (angle at TL) +135° with distance (TL-Td) 4. setbulge at nth vertex Edited December 12, 2019 by hanhphuc add dtr function , img & additional comments in red Quote
Sambuddy Posted December 11, 2019 Author Posted December 11, 2019 Thank you hanhphuc for your explanation. It is greatly appreciate it. I am sure i will use your instructions on my other codes - thank you for putting some effort to even drawing the angle with labels! Quote
hanhphuc Posted December 12, 2019 Posted December 12, 2019 16 hours ago, Sambuddy said: Thank you hanhphuc for your explanation. It is greatly appreciate it. I am sure i will use your instructions on my other codes - thank you for putting some effort to even drawing the angle with labels! It's glad you make good use of this forum posting your own code for discussions! This is fine which we are willing to share ideas & suggestions. Due to i'm not familiar to your design criterial so I just assume the input sequence from larger to smaller value, i.e: Angle size -> Break distance -> Web thickness. In the example I use and , iniget to avoid inputting invalid values like negative zero, you can set the rules to avoid error using logical if or cond. we'll be happy to see your progress & improvements! p/s: I edited previous comment which is not A+135° confusing, it should be angle at TL+135° Quote
Roy_043 Posted December 12, 2019 Posted December 12, 2019 @hanhphuc: You have: Td=2*R*sin(A/2) I would say this should be: Td=R*tan(A/2) 1 Quote
Sambuddy Posted December 12, 2019 Author Posted December 12, 2019 Thank you hanhpjuc, Since joining CadTutor website and seeking help or guidance, to date, I have created 14 on my own and 42 with guidance from this website. It is sometimes amazes me how some people on this platform go out of their way to spend so much time and effort on an idea someone posts! 1 Quote
BIGAL Posted December 13, 2019 Posted December 13, 2019 You get more support here by having a go than a few here who just keep asking for others to do the work. This may be of help was a response to your prior questions forgot to hit Submit button. 1 check that radius is not more than the parallel width so stop. Sometimes when it gives a zero line length can cause problems. 2 You can draw arcs as part of a pline may be a better way to go, This is an example of a double arc arrangement in a pline. (command "pLINE" p2 "w" 0.0 0.0) (setq p3 (polar p2 ang1 d2)) (setq p4 (polar p3 ang1 d2)) (setq p5 (polar (polar p3 ang1 20)(+ ang1 4.71239) d3)) (setq p6 (polar p5 ang1 d2 )) (setq p7 (polar p6 ang1 d2)) (setq p8 (polar p4 ang1 d4)) ; now put pts 3,4,5,6 (command "a" "ce" p3 "a" "-180" "l" p5 "a" "ce" p6 p7 "l" p8) (command "") 1 Quote
hanhphuc Posted December 13, 2019 Posted December 13, 2019 On 12/12/2019 at 4:21 PM, Roy_043 said: @hanhphuc: You have: Td=2*R*sin(A/2) I would say this should be: Td=R*tan(A/2) thanks @Roy_043 yes it should be the correct way for tangent length Td=R*tan(A/2). i should have explained correctly. The reason i used Td=2*R*sin(A/2) due to OP's angle applied angle is 60°, it equals to Td=R*tan(A/2) only applicable if A=120° with chord 60°x3 (red triangle) which i previously mentioned chord length & Td length both indentical. (setq R 1) (* 2 R (sin (dtr (/ 120 2)))) ;1.73205 (* R (tan (dtr (/ 120 2)))) ;1.73205 i apology for the confusions. Hope OP will take note too dealing with angle out of 60° criteria Quote
hanhphuc Posted December 14, 2019 Posted December 14, 2019 (edited) On 12/13/2019 at 8:13 AM, BIGAL said: 1 check that radius is not more than the parallel width so stop. Sometimes when it gives a zero line length can cause problems. 2 You can draw arcs as part of a pline may be a better way to go, OP's criteria of radius is constraint i.e: R=web x 0.75, but incorrect parameters e.g: web too thick or too narrow may yield unwanted results. use cond Edited December 14, 2019 by hanhphuc large = thick 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.