Sheep Posted August 5, 2020 Posted August 5, 2020 Hello to all. Hope everyone feeling great. Can someone help me with this. I want to make a line from Line 01 to Line 02. The length of the line base on user input. The mid of the new line must parallel with the intersection of Line 01 and Line 02. Let say the line is 10 and i just pick Line 01 and Line 02 and LISP will create a line within Line 01 and Line 02. I hope you guys can understand. Thank you for your time. Quote
Lee Mac Posted August 5, 2020 Posted August 5, 2020 @Sheep Which line in your image is the end result? Quote
Sheep Posted August 6, 2020 Author Posted August 6, 2020 (edited) 9 hours ago, Lee Mac said: @Sheep Which line in your image is the end result? Thanks for your reply @Lee Mac. Below is the end result that i'm looking for. Maybe i should rephrase my question. The lines mid (red) don't have to be parallel OR parallel to the intersection (the top circle) as long as the line fits between both side lines. For example the line is 10m and both end of that line must connect to the side lines. Tried making rectangle but the problem is i have to place it manually. I have almost 120 rectangles (and they are different length) to make and that is taking so much time. My LISP is at the most basic level, so VLisp is too hard for me to understand. Can you please guide me in autolisp? Thank you for your time. Edited August 6, 2020 by Sheep Quote
Sheep Posted August 6, 2020 Author Posted August 6, 2020 16 hours ago, eldon said: Perhaps you mean like Chamfer with No Trim? Will the line (with different length) fits between the side line? Quote
Sheep Posted August 6, 2020 Author Posted August 6, 2020 (edited) By breaking things down, i used only the left side to make a triagle. By using the calculation from CosSinCalc, that is as close i can get ( still OK). Now, how do i get the angle? Do i have to DIMANG all the time? Edited August 6, 2020 by Sheep Quote
BIGAL Posted August 6, 2020 Posted August 6, 2020 Is it not this red line is the intersect with circle points. Quote
Sheep Posted August 6, 2020 Author Posted August 6, 2020 What about the length of the red line? Let say 10m, how can i make it 10m by using a circle? Quote
eldon Posted August 6, 2020 Posted August 6, 2020 (edited) 5 hours ago, Sheep said: Will the line (with different length) fits between the side line? That is what Chamfer does. You would have to put in the correct distance from the intersection point. Edited August 6, 2020 by eldon Quote
Sheep Posted August 6, 2020 Author Posted August 6, 2020 (edited) 27 minutes ago, eldon said: That is what Chamfer does. You would have to put in the correct distance from the intersection point. Thank you for the reply. The problem is, no distance was supply from the intersection. Just the length of the line (10m). How about FILLET--NO TRIM--RADIUS? Will it work? If yes, how do i write the code? I might can work out the rest if i use the radius to get the point on both side lines. (command "FILLET" Line_1 "R" Radius_Curve "" "TRIM" "N" Line_2 "") Edited August 6, 2020 by Sheep Quote
guran Posted August 6, 2020 Posted August 6, 2020 You draw a "XLINE / Bisect" through the intersection and offset the 0:5m in both directions. 1 Quote
Sheep Posted August 6, 2020 Author Posted August 6, 2020 6 minutes ago, guran said: You draw a "XLINE / Bisect" through the intersection and offset the 0:5m in both directions. Sorry, not following you. Can you please give an example please. Quote
BIGAL Posted August 7, 2020 Posted August 7, 2020 (edited) Sin= 0/H Cos = A/H tan= O/A Others have a habit of answering. Of the top of my head 1/cos (90-118/2) * (dist / 2) = 5.83 So can work out point after using ang1 ang2 intersectwith for intersection point. Then polar 5.8331669860910269322409769334776 along in correct direction. If you use a circle and intersectwith will have problems. Edited August 7, 2020 by BIGAL Quote
Sheep Posted August 12, 2020 Author Posted August 12, 2020 On 8/5/2020 at 6:06 PM, eldon said: Perhaps you mean like Chamfer with No Trim? Can you please give the autolisp code to do that please? Quote
eldon Posted August 12, 2020 Posted August 12, 2020 3 hours ago, Sheep said: Can you please give the autolisp code to do that please? I afraid that your request is against my principles and also beyond my capabilities. Quote
Sheep Posted August 12, 2020 Author Posted August 12, 2020 4 minutes ago, eldon said: I afraid that your request is against my principles and also beyond my capabilities. that's ok. Quote
Sheep Posted August 12, 2020 Author Posted August 12, 2020 Can someone help me. I can't create a triangle. (command "fillet" "trim" "N" L_1 L_2 ) (setq data_radius (entget (car (entsel)))) (setq Assoc10 (cdr (assoc 10 data_radius))) (setq Assoc11 (cdr (assoc 10 (reverse data_radius)))) (setq cen_radius (cdr (assoc 40 data_radius))) (command "PLINE" cen_radius Assoc10 Assoc11 "C" ) Quote
Jonathan Handojo Posted August 12, 2020 Posted August 12, 2020 (edited) Unfortunately I'm still using VL methods... (Because they're amazing). This should get what you want. (defun c:test (/ *error* acadobj activeundo adoc crc d1 d2 dis getline gr grp grv intr ints lck len ln1 ln2 lnint lns msp p p1 p2 pt s) (defun *error* ( msg ) (redraw) (mapcar '(lambda (x) (if x (vla-Highlight x :vlax-false))) (list ln1 ln2)) (and crc (null (vlax-erased-p crc)) (vla-Delete crc)) (if lck (entmod (subst lck (assoc 70 (tblsearch "layer" (getvar 'clayer))) (entget (tblobjname "layer" (getvar 'clayer))) ) ) ) (vla-EndUndoMark adoc) (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*")) (princ (strcat "Error: " msg)) ) ) (setq acadobj (vlax-get-acad-object) adoc (vla-get-ActiveDocument acadobj) msp (vla-get-ModelSpace adoc) activeundo nil) (if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T)) (defun getline (msg / ln) (while (progn (setvar 'errno 0) (setq ln (car (entsel msg))) (cond ((= (getvar 'errno) 7) (princ "\nNothing selected")) ((null ln) nil) ((not (eq (cdr (assoc 0 (entget ln))) "LINE")) (princ "\nObject is not a line")) ) ) ) (if ln (vlax-ename->vla-object ln)) ) (if (and (setq ln1 (getline "\nSelect first line <exit>: ")) (setq ln2 (getline "\nSelect second line <exit>: ")) (if (null (setq lnint (vlax-invoke ln1 'IntersectWith ln2 acExtendBoth))) (not (princ "\nLines are parallel or do not have an intersection.")) t) (setq dis (progn (initget 6) (getdist "\nSpecify line distance <exit>: "))) ) (progn (vla-Highlight ln1 :vlax-true) (if (= 4 (logand 4 (cdr (setq lck (assoc 70 (tblsearch "layer" (getvar 'clayer))))))) (entmod (subst (cons 70 (- (cdr lck) 4)) lck (entget (tblobjname "layer" (getvar 'clayer))))) ) (princ "\nSpecify point [Switch/Distance/Middle]: ") (while (progn (setq gr (grread t 15 0) grp (cadr gr) grv (car gr) ) (cond ((= grv 5) (redraw) (grdraw grp (setq pt (vlax-curve-getClosestPointTo (if s ln2 ln1) grp)) 3 1) (setq crc (vla-AddCircle msp (vlax-3d-point pt) dis) ints (vlax-invoke crc 'IntersectWith (if s ln1 ln2) acExtendNone) lns nil ) (while ints (if (equal (distance pt (setq intr (list (car ints) (cadr ints) (caddr ints)))) dis 1e-4) (progn (grdraw pt intr 1) (setq lns (cons intr lns)) ) ) (setq ints (cdddr ints)) ) (vla-Delete crc) t ) ((= grv 2) (cond ((member grp '(68 100)) (setq dis (cond ((getdist (strcat "\nSpecify line distance <" (vl-princ-to-string dis) ">: "))) (dis))) (princ "\nSpecify point [Switch/Distance/Middle]: ") ) ((member grp '(83 115)) (if s (progn (setq s nil) (vla-Highlight ln1 :vlax-true) (vla-Highlight ln2 :vlax-false)) (progn (setq s t) (vla-Highlight ln2 :vlax-true) (vla-Highlight ln1 :vlax-false)) ) t ) ((member grp '(77 109)) (setq d1 (vlax-curve-getDistAtPoint (if s ln2 ln1) lnint) d2 (vlax-curve-getDistAtPoint (if s ln1 ln2) lnint) p (vlax-curve-getDistAtPoint (if s ln2 ln1) pt) ) (foreach x lns (setq len (/ dis (sqrt (* 2 (- 1 (cos (JH:InnerAngle pt lnint x)))))) p2 (vlax-curve-getDistAtPoint (if s ln1 ln2) x) p1 (vlax-curve-getPointAtDist (if s ln2 ln1) ((if (< d1 p) + -) d1 len)) p2 (vlax-curve-getPointAtDist (if s ln1 ln2) ((if (< d2 p2) + -) d2 len)) ) (if (and p1 p2) (entmake (list '(0 . "LINE") (cons 10 p1) (cons 11 p2)))) ) t ) ((member grp '(13 32)) nil) (T) ) ) ((= grv 3) (foreach x lns (entmake (list '(0 . "LINE") (cons 10 pt) (cons 11 x)))) t ) ((= grv 25) nil) (T) ) ) ) (redraw) (mapcar 'vla-Highlight (list ln1 ln2) '(:vlax-false :vlax-false)) (entmod (subst lck (assoc 70 (tblsearch "layer" (getvar 'clayer))) (entget (tblobjname "layer" (getvar 'clayer))) ) ) ) ) (if activeundo nil (vla-EndUndoMark adoc)) (princ) ) ;; JH:InnerAngle --> Jonathan Handojo ;; Returns the smaller angle between three point p1 p2 p3 ;; with p2 as the pivot, in radians. (defun JH:InnerAngle (p1 p2 p3 / 2p ang) (setq ang (- (angle p2 p3) (angle p2 p1)) 2p (+ pi pi)) (while (not (<= 0 ang 2p)) (if (< ang 0) (setq ang (+ ang 2p)) (setq ang (- ang 2p)))) (if (> ang pi) (- 2p ang) ang) ) Edited August 12, 2020 by Jonathan Handojo Quote
BIGAL Posted August 12, 2020 Posted August 12, 2020 Nice jonathon using my math approach I think the code would be about a 1/4 of what you have done. Sheep you need to have a go. This is a non vl method. Pick line 1 away from intersection get start and end points use check end to work out direction of line Pick line 2 away from intersection get start and end points use check end to work out direction of line Use inters function non Vl to get intersection point Use the formula I provided to work out distance along line. Use polar from inter point along line1 for calculated distance pt1 Use polar from inter point along line2 for calculated distance pt2 Draw line pt1 pt2 here is check end (setq tp1 (entsel "\nSelect line near end : ")) (setq tpp1 (entget (car tp1))) (setq pt1 (cdr (assoc 10 tpp1))) (setq pt1 (list (car pt1) (cadr pt1) 0.0)) ;reset z to zero (setq pt2 (cdr (assoc 11 tpp1))) (setq pt2 (list (car pt2) (cadr pt2) 0.0)) ;reset z to zero (setq pt3 (cadr tp1)) (setq d1 (distance pt1 pt3)) (setq d2 (distance pt2 pt3)) (if (> d1 d2) (progn (setq temp pt1) (setq pt1 pt2) (setq pt2 temp) ) ) (setq ang (angle pt1 pt2) 1 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.