Author Topic: Automatic Nesting for lisp?  (Read 26886 times)

0 Members and 1 Guest are viewing this topic.

well20152016

  • Newt
  • Posts: 130
Automatic Nesting for lisp?
« on: November 10, 2016, 08:22:59 AM »
 Automatic Nesting
« Last Edit: December 04, 2016, 10:10:03 AM by well20152016 »

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Automatic Nesting for lisp?
« Reply #1 on: November 10, 2016, 09:51:32 AM »
I need google to translate to for me known language... Sorry...

P.S. What is 2440x1220 in dialog box?
P.S.S. Now that you solved the task in 2D, my next advice for you is to try to solve it in 3D with boxes... (not obligation, just my remark...)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ChrisCarlson

  • Guest
Re: Automatic Nesting for lisp?
« Reply #2 on: November 10, 2016, 10:22:48 AM »
I don't see a question here?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Automatic Nesting for lisp?
« Reply #3 on: November 10, 2016, 10:25:11 AM »
P.S. What is 2440x1220 in dialog box?
Probably the dimensions of a sheet of plywood.

@well20152016:
How about irregular shapes?

well20152016

  • Newt
  • Posts: 130
Re: Automatic Nesting for lisp?
« Reply #4 on: November 10, 2016, 11:08:53 AM »
Many small rectangles, placed inside a large rectangle!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Automatic Nesting for lisp?
« Reply #5 on: November 10, 2016, 11:17:47 AM »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Automatic Nesting for lisp?
« Reply #6 on: November 10, 2016, 11:53:41 AM »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Automatic Nesting for lisp?
« Reply #7 on: November 10, 2016, 12:34:59 PM »
I don't see a question here?
I have a question:
Code: [Select]
;--------|-----------------------------|-------------------|
;   10   | description        | string            |
;--------|-----------------------------|-------------------|
;   20   | length        | real              |
;--------|-----------------------------|-------------------|
;   30   | width        | real              |
;--------|-----------------------------|-------------------|
;   50   | preference index            | real              |
;--------|-----------------------------|-------------------|
;
(;Wood panel code
 ("CP09702220"  (10 . "Wood panel   970x2220")(20 .  970)(30 . 2220)(50 . 80))
 ("CP06152950"  (10 . "Wood panel   615x2950")(20 .  615)(30 . 2950)(50 . 20))
 ("CP14602950"  (10 . "Wood panel  1460x2950")(20 . 1460)(30 . 2950)(50 . 20))
)
;Example: CP14602950 = panel from commerce 1460x2950 - first dimension is the mood sense

; blade thickness = 3 (variable)

(;cutting list: quantity - length - width >  first dimension is the mood sense
  (3 1015 390) (57 490 1205) ...
)
Find the minimum number of panel proposing the computation starting at the highest preference index with the minimum number of rotations of the panel on the cutting machine (i.e. see the sequence A-B-C-D-F).
Does anyone know a similar program (also to buy)?


well20152016

  • Newt
  • Posts: 130
Re: Automatic Nesting for lisp?
« Reply #8 on: November 10, 2016, 01:46:25 PM »
There should be a good algorithm, with the completion of lisp. Thank you

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Automatic Nesting for lisp?
« Reply #9 on: November 10, 2016, 01:49:21 PM »
I've always used (and continue to recommend) MyNesting for this task.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Automatic Nesting for lisp?
« Reply #10 on: November 11, 2016, 01:51:53 AM »
I've always used (and continue to recommend) MyNesting for this task.
Very interesting, but is there something about the cutting of wood panels with circular blade?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Automatic Nesting for lisp?
« Reply #11 on: November 11, 2016, 09:02:11 AM »
Sorry this is the correct schema (one rotation in less):

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: Automatic Nesting for lisp?
« Reply #12 on: November 11, 2016, 09:42:03 AM »
grained and non grained materials? cutting tool thickness?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Automatic Nesting for lisp?
« Reply #13 on: November 11, 2016, 11:12:18 AM »
grained and non grained materials? cutting tool thickness?
Sorry for my english, I wrote "mood sense":
;Example: CP14602950 = panel from commerce 1460x2950 - first dimension is the mood sense
; blade thickness = 3 (variable)
;cutting list: quantity - length - width >  first dimension is the mood sense

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Automatic Nesting for lisp?
« Reply #14 on: November 11, 2016, 04:00:46 PM »
Reply to animated gif... Not 100% sure, but this is my simple version... Should work with imaginary rectangular bounding boxes like posted gif, but my version is using one single rectangle for entity where nesting is expected...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:nesting ( / *adoc* ss s bndr minp maxp w h i e eminp emaxp ew eh el x y bp ell elll )
  2.  
  3.  
  4.   (prompt "\nSelect nesting 2D entities...")
  5.   (setq ss (ssget "_:L"))
  6.   (prompt "\nPick boundary rectangle to nest to...")
  7.   (setq s (ssget "_+.:E:S" (list '(0 . "LWPOLYLINE") '(90 . 4) '(-4 . "<or") '(70 . 1) '(70 . 129) '(-4 . "or>") '(-4 . "<not") '(-4 . "<>") '(42 . 0.0) '(-4 . "not>"))))
  8.   (setq bndr (ssname s 0))
  9.   (vla-getboundingbox (vlax-ename->vla-object bndr) 'minp 'maxp)
  10.   (mapcar 'set '(minp maxp) (mapcar 'safearray-value (list minp maxp)))
  11.   (setq w (- (car maxp) (car minp)))
  12.   (setq h (- (cadr maxp) (cadr minp)))
  13.   (repeat (setq i (sslength ss))
  14.     (setq e (ssname ss (setq i (1- i))))
  15.     (vla-getboundingbox (vlax-ename->vla-object e) 'eminp 'emaxp)
  16.     (mapcar 'set '(eminp emaxp) (mapcar 'safearray-value (list eminp emaxp)))
  17.     (setq ew (- (car emaxp) (car eminp)))
  18.     (setq eh (- (cadr emaxp) (cadr eminp)))
  19.     (setq el (cons (list eminp ew eh e) el))
  20.   )
  21.   (setq el (vl-sort el '(lambda ( a b ) (if (equal (caddr a) (caddr b) 1e-3) (< (cadr a) (cadr b)) (< (caddr a) (caddr b))))))
  22.   (while
  23.     (and
  24.       (car el)
  25.       (<
  26.         (cond
  27.           ( (null x) (setq x 0.0 y 0.0) x )
  28.           ( (> (+ x (cadar el)) w)
  29.             (setq x 0.0)
  30.             (foreach e elll
  31.               (setq ell (vl-remove e ell))
  32.             )
  33.             (setq elll ell)
  34.             (vl-some
  35.              '(lambda ( e )
  36.                 (if (< (cadar el) (car e))
  37.                   (setq y (+ (cadr e) (caddr (caddr e))))
  38.                 )
  39.               )
  40.               (reverse ell)
  41.             )
  42.             x
  43.           )
  44.           ( t
  45.             (if
  46.               (not
  47.                 (vl-some
  48.                  '(lambda ( e )
  49.                     (if (< (+ x (cadar el)) (car e))
  50.                       (setq y (+ (cadr e) (caddr (caddr e))))
  51.                     )
  52.                   )
  53.                   (reverse ell)
  54.                 )
  55.               )
  56.               (vl-some
  57.                '(lambda ( e )
  58.                   (if (or (< (+ x (cadar el)) (car e)) (< (+ x 1e-3) (car e)))
  59.                     (setq y (+ (cadr e) (caddr (caddr e))))
  60.                   )
  61.                 )
  62.                 (vl-sort ell '(lambda ( a b ) (> (car a) (car b))))
  63.               )
  64.             )
  65.             x
  66.           )
  67.         )
  68.         w
  69.       )
  70.       (or (< (+ y (caddar el)) h) (equal (+ y (caddar el)) h 1e-3))
  71.     )
  72.     (if (= x 0.0)
  73.       (setq bp (list (car minp) (+ y (cadr minp)) 0.0))
  74.       (setq bp (list (+ x (car minp)) (+ y (cadr minp)) 0.0))
  75.     )
  76.     (setq x (+ x (cadar el)))
  77.     (vla-move (vlax-ename->vla-object (cadddr (car el))) (vlax-3d-point (caar el)) (vlax-3d-point bp))
  78.     (setq ell (cons (list x y (car el)) ell))
  79.     (setq el (cdr el))
  80.   )
  81.   (vla-endundomark *adoc*)
  82.   (princ)
  83. )
  84.  

Regards, M.R.
« Last Edit: November 11, 2016, 07:02:09 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube