Jump to content

lots lines to process


ponchote

Recommended Posts

I need to develop something to speedup the process of cutting files.

 

into the pieces I have lots of single lines named slits that i need to transform in some kind of block that must be part of the shape. please see the picture and attached file. im not sure if is a good idea to try it on VBA or maybe Lisp can helps.

 

any idea or help? thanks in advance.

linestoslits.dwg

Link to comment
Share on other sites

Are you trying to turn the white line work over to the green line work? Meaning... in the white line work you have tiny slits represented as a single polyline, and in the green line work they are represented as two polylines 0.02 units apart and parallel. May I ask what this is for? What are you drawing?

 

Thoughts for algorithm.

 

1. Use a bpoly to retrace the inside of each item - Call this Polyline A. (The single lines protruding inward will not be picked up by bpoly and therefor not a part of Polyline A.)

 

2. For each polyline of the original see if any point lies inside the Polyline A. If you find one we know that is a single line protruding inward. Call this Point 1.

 

3. From that point 1 (that lies inside Polyline A) get the angle to its next verice (point temp), add 90 degrees to the right and go 0.02 units and call this point 2.

 

4. Draw a line from point 1 to point 2. from point 2 go on angle of Point 1 to Point temp and intersect polyline A. Call this Point 3. Draw Line from point 2 to point 3.

 

5. Do another bpoly. Call it Polyline B. This will be the resulting polyline that you are looking for. Explode Polyline B if desired.

 

Example.jpg

 

The red polyline is Polyline A.

Edited by Hippe013
Link to comment
Share on other sites

Hippe013 maybe explode all, make bpoly like you say, offset inward use ssget "F" (list of offset pline points) the selection set will return all the individual slit lines and info like angle of line. Need L&R offset plus end then trim bpoly and add the 3 new legs probably just use fillet to add the slit. I have a intersect routine for two lines and a pline touching or not.

Link to comment
Share on other sites

This files are used to cut this shapes on a water jet machine but if I load the file with the slits the machine turns of and turn on the water pump on each slit, then processing the slits we are making one poliline all around the shape and the cutting process is faster and better.

 

Make an a offset left or right can works .020 is not a big problem actually I'm

Making this lateral offset and conecting this parallel lines .. unfortunately one by one. And believe me is not fun :(

Link to comment
Share on other sites

This is a start needs some cleaning up but it works, it will do multiple shapes as required creating a new pline. But it errors sometimes.

 

Found out just zoom in a bit it does not like zoomed out when picking inside.

 

Ponchote you must explode all before running ! I expect you will have some more questions.

 

; pline co-ords example
; By Alan H
(defun getcoords (ent)
(vlax-safearray->list
(vlax-variant-value 
(vlax-get-property 
(vlax-ename->vla-object ent) 
"Coordinates" 
) 
) 
)
)
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(defun co-ords2xy ( / xy)
(setq len (length co-ords))
(setq numb (/ len 2)) ; even and odd check required
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
) ; co-ords2xy

; rule 1 is that start point is always on pline
; draw two lines so convex or concave works
(defun ah:slit (obj obj1 / ent10 ent11 pt1 pt2 pt3 pt4 pt5 pt6 obj2 obj3 intpt1 intpt2)
(setq ent10 (assoc 10 (entget obj)))
(setq pt1 (list (cadr ent10)(caddr ent10)))
(setq ent11 (assoc 11 (entget obj)))
(setq pt2 (list (cadr ent11)(caddr ent11)))
(setq ang (angle pt2 pt1))
(setvar "osmode" 0)
(setq pt3 (polar pt2 (+ (/ pi 2.0) ang) 0.02))
(setq pt4 (polar pt2 (- ang (/ pi 2.0) ) 0.02))
(setq pt5 (polar pt3 ang 1))
(setq pt6 (polar pt4 ang 1))
(command "line" pt6 pt4 "")
(setq obj2 (vlax-ename->vla-object (entlast)))
(command "line" pt5 pt3 "")
(setq obj3 (vlax-ename->vla-object (entlast)))
(setq intpt1 (vlax-invoke obj2 'intersectWith obj1 acExtendnone))
(setq intpt2 (vlax-invoke obj3 'intersectWith obj1 acExtendnone))
(command "_break" pickobj intpt1 intpt2)
;(command "erase" obj "") ; this is the original line if want to delete
(vla-delete obj2)
(vla-delete obj3)
(command "pline" intpt1 pt4 pt3 intpt2 "")
(setq obj2 (entlast))
(command "pedit" pickobj "j" obj2 "" "")
(princ)
) ; defun

; starts here 
; explode shape then premake bpoly
(defun c:mkslit ( / pt0 pickobj obj1 obj ss co-ordsxy)
(command "-layer" "m" "poly" "c" 1 "poly" "")
(setq pt0 (getpoint "pick inside shape"))
(command "_bpoly" pt0 "")
(setq pickobj (entlast)) ; pick bpoly this should be done once only
(setq obj1 (vlax-ename->vla-object pickobj)) ; convert to vl object needed for intersect
(command "offset" 0.05 pickobj pt0 "")
(setq co-ords (getcoords (entlast)))
(princ (co-ords2xy))
(command "erase" (entlast) "")
(setq ss (ssget "_CP" co-ordsxy (list (cons 0 "line"))))
(repeat (setq x (sslength ss))
(setq obj (ssname ss (setq x (- x 1))))
(ah:slit obj obj1)
) ; repeat
(princ)
) ; mkslit

(c:mkslit) ; 1st time run on load

Edited by BIGAL
Link to comment
Share on other sites

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