Jump to content

Recommended Posts

Posted

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

Posted

looking at my splines i find that i need to sort them by the "control point Z" flag somehow

Posted

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)

Posted

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: #

 

elevation.jpg

 

this is a part of the drawing on trying to do this on

 

spline_test.dwg

Posted

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

Posted

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)

)

Posted

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

Posted

You did all the heavy lifting on this one, BIGAL. I don't do VLISP so I just tweaked it a little.

:notworthy:

Posted

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

Posted

Yes, let us know how the routing comes out. It's nice to see real-world results!

Posted

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 :o

Posted

Flatten generally means to set Z=0, you need to look for 3d Spline to 3d Polyline or Line conversion.

  • 4 weeks later...
Posted

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

 

 

DSC_0081.jpg

DSC_0071.jpg

DSC_0063.jpg

Posted

That's really impressive! Thanks for posting the pics. I think I can smell fresh cut sawdust...

:)

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