Anushka Posted December 27, 2023 Posted December 27, 2023 I'm looking for an efficient way to add length to a polyline. Currently, I create an entity with the desired length and embed it into the polyline. However, it takes time and some lengths take up a lot of space in the project. How to do this smarter and faster?? This serves to outline that my polyline has a reserve in the posts and this length must be taken into account when purchasing the material. (Happy holidays everyone!!) reservation in the polyline.dwg Quote
BIGAL Posted December 28, 2023 Posted December 28, 2023 Ok manually break pline with 1.0 gap, insert block 35M with correct rotation, explode block, JOIN 3 plines all done. Ok looking at dwg make gap between 35m = 1.0000 not 1.0199. Make 2 blocks as required of pline and more if required, pick left start of pline as insert point. So pretty easy you need to do home work 1st making blocks then can choose correct block on the fly. 20M, 30M, 35M and so on. At least make 2 for testing. Quote
Steven P Posted December 28, 2023 Posted December 28, 2023 Something that is for something else, but will do as a starter here: Removes a segment of polyline (defun c:RemovePortion ( / pt1 pt2 MyPL MySegment MySegPts) (defun ODlinetopt ( MyLine TrimPt1 TrimPt2 / MyLineDef MyLineEndA MyLineEndB Pt1Dist Pt2Dist TempPT MyLineA MyLineB) (command "zoom" "Object" MyLine "") (command "zoom" "0.95x") (setq MyLineDef (entget MyLine)) (setq MyLineEndA (cdr (assoc 10 MyLineDef))) (if (= (cdr (assoc 0 MyLineDef)) "LINE") (setq MyLineEndB (cdr (assoc 11 MyLineDef))) (setq MyLineEndB (cdr (assoc 10 (reverse MyLineDef)))) ) ;;sort trimpts according to distance from end A (setq Pt1Dist (vlax-curve-getdistatpoint MyLine (osnap TrimPt1 "nea")) ) (setq Pt2Dist (vlax-curve-getdistatpoint MyLine (osnap TrimPt2 "nea")) ) (if ( > Pt1Dist Pt2Dist) (progn (setq TempPt TrimPt1) (setq TrimPt1 TrimPt2) (setq TrimPt2 TempPt) ) ;end progn ) ;end if (command "breakatpoint" MyLine TrimPt1) (setq MyLineA (entlast)) (command "breakatpoint" MyLineA TrimPt2) (setq MyLineB (entlast)) (command "zoom" "Previous") (command "zoom" "Previous") MyLineA ) ;; Ref Lee Mac ;; (defun mAssoc ( key lst / result ) ;; (foreach x lst ;; (if (= key (car x)) ;; (setq result (cons (cdr x) result)) ;; ) ;; ) ;; (reverse result) ;; ) (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark thisdrawing) (setq pt1 (getpoint "Get point 1")) (setq pt2 (getpoint "Get point 1")) (setq MyPL (car (entsel "Get Line"))) (setq MySegment (ODlinetopt MyPl Pt1 Pt2) ) ;; (setq MySegPts (mAssoc 10 (entget MySegment))) (entdel MySegment) (vla-endundomark thisdrawing) ) 1 Quote
BIGAL Posted December 29, 2023 Posted December 29, 2023 Like Steven P something like this. I am pretty sure need a CCW CW check, I only made block 40M for testing. How you going making sample blocks ? Need names to complete this. ; bY AlanH DEC 2023 (defun c:xwire ( / oldsnap oldaunits obj ent ent2 pt1 pt2 pt) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq oldaunits (getvar aunits)) (setvar 'aunits 3) (setq ent (entsel "\nPick pline at break pt")) (setq obj (vlax-ename->vla-object (car ent))) (setq start (vlax-curve-getstartPoint obj)) (setq end (vlax-curve-getEndPoint obj)) (setq pt (cadr ent)) (setq pt (vlax-curve-getclosestpointto obj pt)) (setq ang (angle start end)) (setq pt1 (polar pt ang 0.5)) (setq pt2 (polar pt (+ ang pi) 0.5)) (command "Break" pt1 pt2) (setq ent2 (entlast)) (command "-insert" "40M" "S" 1.0 pt2 ang) (command "explode" (entlast)) (command "join" ent (entlast) ent2 "") (setvar 'osode oldsnap) (setvar 'aunits oldaunits) (princ) ) (c:xwire) Front end, need block names. 1 1 Quote
Anushka Posted December 29, 2023 Author Posted December 29, 2023 This works well, @BIGAL; however, it doesn't merge all the polylines, only the first one. Quote
Anushka Posted December 29, 2023 Author Posted December 29, 2023 Another point to note is that she is consistently on one side, but at times, she may be in the opposite direction. Quote
Anushka Posted December 29, 2023 Author Posted December 29, 2023 Thank you very much, @Steven P This is a good starting point. Quote
Steven P Posted December 29, 2023 Posted December 29, 2023 7 hours ago, Anushka said: This works well, @BIGAL; however, it doesn't merge all the polylines, only the first one. Works for me, A couple of typos: (setq oldaunits (getvar 'aunits)) (setvar 'osmode oldsnap) That amuses me, not sure I can think of a use just yet but its nice. Quote
BIGAL Posted December 29, 2023 Posted December 29, 2023 (edited) Typo's fixed thanks Steven P. Anushka I need to add a direction check so the block will always be say to bottom and to right. A mirror block check. The dwg was limited in the number of sample lines, are they in any direction ? It did not join did you make block 40M and did you fix the 1.019 to now be 1.0 between the pline ends. That 0.019 will make it not join. Still need the block names, so can add the choice part. Double posted over at Forums/Autodesk. It is a good idea to wait a bit before double posting. Edited December 29, 2023 by BIGAL 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.