Franchizai Posted May 1, 2017 Posted May 1, 2017 Her folks Im looking for A Way to sort polylines into layers based On the z value. Ive done this manually for A while to make simple 3D contours for my cnc. Basically i just need A routine the reads the z value and moves or copies the contuer into A layer called geometry_(zvalue) is that possible and Can someone point my in the right direction pls Forgift to mention im using autocad 2010 Quote
Franchizai Posted May 1, 2017 Author Posted May 1, 2017 looking at my splines i find that i need to sort them by the "control point Z" flag somehow Quote
BIGAL Posted May 2, 2017 Posted May 2, 2017 Try this a bit rough but with no sample dwg to test. (defun layzs ( / ss x elev lay obj) (setq ss (ssget)) ; pick objects ;(setq ss (ssget (list (cons 0 "lwpolyline")))) ; use a filter (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq elev (vla-get-Elevation obj)) (setq lay (strcat "layz-" (rtos elev 2 1))) (command "-layer" "m" lay "") (vla-put-layer obj lay) ) ) (layzs) Quote
Franchizai Posted May 2, 2017 Author Posted May 2, 2017 im trying to get my head around how this works and im sneaking in on it for some reason i get this error and i cant figure out why. i tried changing "vla-get-elevation" to "vla-get-controlpoints" this gives me an error in (rtos elev 2 1) ; error: bad argument type: numberp: # this is a part of the drawing on trying to do this on spline_test.dwg Quote
Franchizai Posted May 2, 2017 Author Posted May 2, 2017 well im guessing its because theres no "Elevation" in a spline and i cant seem to find a "vla-get-control point z" but maybe theres another way Quote
BKT Posted May 2, 2017 Posted May 2, 2017 Assuming all entities are splines, and until something else comes along, give this a try: (defun c:test (/ ss obj elev lay) (setq ss (ssget (list (cons 0 "SPLINE")))) (repeat (setq x (sslength ss)) (setq obj (ssname ss (setq x (- x 1)))) (setq elev (caddr (cdr (assoc 10 (entget obj))))) (setq lay (strcat "geometry_" (rtos elev 2 1))) (command "-layer" "m" lay "") (command "._change" obj "" "p" "la" lay "") ) (princ) ) Quote
BIGAL Posted May 3, 2017 Posted May 3, 2017 Thanks BKT I just tested the easy one ie plines, the obvious thing to do is a cond for pline, line, spline etc as all your after is the Z. A 2d pline has a Elev but not a Z (assoc 39). A 3dpoly is similar in that you could get the first vertice and retrieve the z value. Same with spline using Vl could get at the vertice Z. Oh yeah need /= 0.0 Quote
BKT Posted May 3, 2017 Posted May 3, 2017 You did all the heavy lifting on this one, BIGAL. I don't do VLISP so I just tweaked it a little. Quote
Franchizai Posted May 4, 2017 Author Posted May 4, 2017 How sweet is that this works perfectly thank alot you guys now to wrap my head around how it actually works so i understand it wil post a pic og the this im routing when its all done : thx a million Quote
BKT Posted May 4, 2017 Posted May 4, 2017 Yes, let us know how the routing comes out. It's nice to see real-world results! Quote
Franchizai Posted May 8, 2017 Author Posted May 8, 2017 works pretty well now i have this problem with some of the splines not being planar and being way to heavy for my machine. i need somthing that can flatten a spline at its current elevation/control point z every flatten i find takes everything to 0.0 Quote
SLW210 Posted May 8, 2017 Posted May 8, 2017 Flatten generally means to set Z=0, you need to look for 3d Spline to 3d Polyline or Line conversion. Quote
Franchizai Posted June 2, 2017 Author Posted June 2, 2017 as promised som pics of the product almost finished nice to see the actual lines in the wood axactly as the cad model. second pictures shows a piece that was routed from programmed from both sides and flipped in the cnc. actually most of the pieces had to be flipped cause of the hole sloping the other way total weight 400kgs of nice oak in finished product Quote
BKT Posted June 2, 2017 Posted June 2, 2017 That's really impressive! Thanks for posting the pics. I think I can smell fresh cut sawdust... 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.