Jump to content

Efficient Techniques for Enlarging Polylines: Adding Length Accurately


Recommended Posts

Posted

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.
ed81c622-9906-4bec-b982-cce33e0b9373.thumb.jpeg.6b9c51737ee385a00319ae409511b602.jpeg

adaptacad_0-1703677574603.png.93d0a21fa40ee3f033958222c59024df.png
(Happy holidays everyone!!)

reservation in the polyline.dwg

Posted

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.

Posted

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)

)

 

  • Like 1
Posted

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.

image.png.43472baad2e29f475e1160a501224bf3.png

 

  • Like 1
  • Thanks 1
Posted

This works well, @BIGAL; however, it doesn't merge all the polylines, only the first one.

Posted

Another point to note is that she is consistently on one side, but at times, she may be in the opposite direction.

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

Posted (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 by BIGAL
  • Like 1

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