Offset polylines

Offset polylines

NoelN.
Contributor Contributor
1,054 Views
14 Replies
Message 1 of 15

Offset polylines

NoelN.
Contributor
Contributor

Hi everyone,

 

Does anybody know if possible if there is a lisp routine to offset overlapping polylines from a certain distance. basically I deal with shapefiles  and data and I import them into Map 3d but when I import them into autocad map3d the multiple polylines are on top of each other. let say I have polylines from a A to D but from point B to point C there are 3 polylines over lapping. I want the polylines equally spaced out with out lossing the data attached to the polylines. Hopefully I explained my self correctly..

0 Likes
1,055 Views
14 Replies
Replies (14)
Message 2 of 15

sby0531
Enthusiast
Enthusiast

I suggest you upload the dwg file showing the result that you want so that we can understand your issues well.

Message 3 of 15

NoelN.
Contributor
Contributor

here it a sample file the top 2 streets where the polyline are seperated is the final and the bottom one is how it comes out when I uploaded the shape files into the CAD Drawing.

0 Likes
Message 4 of 15

Sea-Haven
Mentor
Mentor

I have a chx chy which does just that moves multiple objects by pick in a direction may be useful, you almost need to redraw the plines so the line is parallel off but has a short end connection back to the node.

 

screenshot211.png

0 Likes
Message 5 of 15

NoelN.
Contributor
Contributor

thank you for that suggestion but I need something automated that will do a large community or area really quick. the suggestion that you mention might take a day or so. 

Message 6 of 15

Sea-Haven
Mentor
Mentor

How many 1000's ? it would look at say 1 layer at a time you enter offset 1st say 3, second -3 so goes other side. When offer suggestions looking at dwg would expect multiple in one go.

 

Your lines are on different layers so what is the problem ? There are say 21 in one layer in dwg provided, that's instant redraw do all in one go.

 

The layer "P-Aerial Distribution Cable" is an easy one to offset, as it appears to have only single segments.

 

 

0 Likes
Message 7 of 15

Sea-Haven
Mentor
Mentor

This is real rough but shows how the while would be removed for multiple selection. Note works on Lines not plines that needs to be added. offset is 8

(defun c:test ( / end start newst newend obj)
(while (setq obj (vlax-ename->vla-object (car (entsel "Pick object "))))
(setq end (vlax-get Obj 'EndPoint))
(setq start (vlax-get Obj 'StartPoint))
(setq ang (angle start end))
(setq newst (polar start ang 22))
(setq newst (polar newst (+ ang (/ pi 2.0)) 22))
(setq newend (polar end (- 0.0 ang) 22))
(setq newend (polar newend (+ ang (/ pi 2.0)) 22))
(setq end (vlax-get Obj 'EndPoint))
(setq start (vlax-get Obj 'StartPoint))
(setq ang (angle start end))
(setq newst (polar start ang 22))
(setq newst (polar newst (+ ang (/ pi 2.0)) 22))
(setq newend (polar end (- 0.0 ang) 22))
(setq newend (polar newend (+ ang (/ pi 2.0)) 22))
(vlax-put Obj 'EndPoint newend)
(vlax-put Obj 'StartPoint newst))
(command "line" newst start "")
(command "line" newend end "")
)
(princ)
)

 

0 Likes
Message 8 of 15

NoelN.
Contributor
Contributor

oh I get what your saying now. not 1000's but it's up in the 100's. So basically anything that is over lapping each other in the sample I want them space equally with just a couple clicks. 

Message 9 of 15

Sea-Haven
Mentor
Mentor

I will clean it up a bit and add some auto do's. Only real question would be offset distance. 

1 Enter offset 0 to exit

2 pick a line carefully as they overlap

3 do selection up to user 1, 2 window etc

0 Likes
Message 10 of 15

lena.talkhina
Alumni
Alumni

Hello @NoelN. !

Great to see you here on LISP forum.

 

Don't hesitate to accept a solution if you find one.

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.



Лена Талхина/Lena Talkhina
Менеджер Сообщества - Русский/Community Manager - Russian

0 Likes
Message 11 of 15

NoelN.
Contributor
Contributor

the offset would 5 in decimal US survey Feet

0 Likes
Message 12 of 15

NoelN.
Contributor
Contributor

Thank you @lena.talkhina. I'm finding great information and people that are happy to help.

0 Likes
Message 13 of 15

Sea-Haven
Mentor
Mentor

Try This please note I isolated the green layer and exploded once so it became line segments between the nodes, so enter offset say 20 pick the green line then window all the green lines. 

 

I am not sure what to do with plines with multi segments I don't think its a quick answer or else diagram loses it joints.

 

Next version would remake pline with the 2 new lines.

 

 

 

; move and draw a chamfer ends to line and pline
; By Alan H info@alanh.com.au  June 2020
; note pline is 2 vertices only

(defun c:test ( / object  ss off tmp)


(defun aH:add-lines (obj offs / end start newst newend ang)
(if (= (vla-get-objectname obj)"AcDbLine")
(progn
(setq end (vlax-get Obj 'EndPoint))
(setq start (vlax-get Obj 'StartPoint))
(setq ang (angle start end))
(setq newst (polar start (+ ang 0.785398163397448) (* 1.414 offs)))
(setq ang (angle end start))
(setq newend (polar end (- ang 0.785398163397448) (* 1.414 offs)))
(vlax-put Obj 'EndPoint newend)
(vlax-put Obj 'StartPoint newst)
(command "line" newst start "")
(command "line" newend end "")
)
(progn
(if (>  (/ (length (vlax-get obj 'Coordinates)) 2) 2)
(alert "Pline has more than 1 segment\n \n Sorry skipped")
(progn
(setq end (vlax-curve-getEndPoint Obj))
(setq start (vlax-curve-getStartPoint Obj))
(setq ang (angle start end))
(setq newst (polar start (+ ang 0.785398163397448) (* 1.4141 offs)))
(setq ang (angle end start))
(setq newend (polar end (- ang 0.785398163397448) (* 1.4141 offs)))
(setq lst (list (car newst)(cadr newst)(car newend)(cadr newend)))
(vlax-put obj 'Coordinates lst)
(command "line" newst start "")
(command "line" newend end "")
)
)
)
)
)

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(if (= off nil)(setq off 20 tmp 20))
(setq off (Getreal (strcat "\nEnter offset 0 to exit  " (rtos off 2 1))))
(if (= off nil)(setq off tmp))
(setq tmp off)
(while (setq ent (car (entsel "\nSelect object for layer")))
(setq lay (vla-get-layer (vlax-ename->vla-object ent)))
(setvar 'clayer lay)
(setq ss (ssget (list (cons 0 "*LINE")(cons 8 lay))))
(if (/= ss nil)
(progn
(repeat (setq x (sslength ss))
(setq object (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(AH:add-lines object off)
)
)
)
)
(princ)
)

 

 

0 Likes
Message 14 of 15

NoelN.
Contributor
Contributor

okay awesome thank you @Sea-Haven, sorry for the late response just got busy with work. thank you for the autolisp but I was wondering if possible to not explode anything, because I have data in the polylines. 

0 Likes
Message 15 of 15

Sea-Haven
Mentor
Mentor

The issue is in the attempting to get a pattern for the multi node connection I may be reading the dwg wrong. 

 

Can you provide a before and after that has different plines, single or multiple. Really need how you want it to look.

0 Likes