pizarro Posted July 24, 2018 Share Posted July 24, 2018 There is some routine in which you can subtract the 3D elements of a layer from the other selected layers ? Thank you for the attention. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted July 24, 2018 Share Posted July 24, 2018 HERE is some example code to subtract items from each other .. although you could probably just pass the items to the subtract command. (defun c:foo (/ l2k l2s) (and (setq l2k (ssget ":L" '((0 . "3dsolid,region") (8 . "layername2keep")))) (setq l2s (ssget ":L" '((0 . "3dsolid,region") (8 . "layername2subtract")))) (command "_.subtract" l2k "" l2s "") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
pizarro Posted August 8, 2018 Author Share Posted August 8, 2018 Adjunt the file for example. I need substract all the elements of the layer BOLTS of the other elements of the layers PLATE, BEAM 01, BEAM 02,... Thank you very much. RESTA DE ELEMENTOS SEGUN LAYER.rar Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 8, 2018 Share Posted August 8, 2018 Maybe: (defun c:foo (/ l2k l2s) (and (setq l2k (ssget "_x" '((0 . "3dsolid,region") (8 . "~bolts")))) (setq l2s (ssget "_x" '((0 . "3dsolid,region") (8 . "bolts")))) (command "_.subtract" l2k "" l2s "") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
pizarro Posted August 8, 2018 Author Share Posted August 8, 2018 Perfect, thank you very much again. Only that the cut elements become one, is it possible to keep the elements separate including the bolts that were used for the cut? thank you very much again. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 9, 2018 Share Posted August 9, 2018 Try this: (defun c:foo (/ l2k l2s) (cond ((and (setq l2k (ssget "_x" '((0 . "3dsolid,region") (8 . "~bolts")))) (setq l2s (ssget "_x" '((0 . "3dsolid,region") (8 . "bolts")))) ) (foreach x (mapcar 'cadr (ssnamex l2s)) (vla-copy (vlax-ename->vla-object x))) (command "_.subtract" l2k "" l2s "") ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
pizarro Posted August 9, 2018 Author Share Posted August 9, 2018 Dear Ronjonp, keep converting the elements into one. Is it possible to keep the elements without becoming one after the subtraction? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 9, 2018 Share Posted August 9, 2018 Dear Ronjonp, keep converting the elements into one. Is it possible to keep the elements without becoming one after the subtraction? I see what you're saying ... gimme a bit. Quote Link to comment Share on other sites More sharing options...
rlx Posted August 9, 2018 Share Posted August 9, 2018 usefull? https://forums.autodesk.com/t5/autocad-forum/how-to-separate-2-solid-objects-joined-by-a-subtraction/td-p/2519230 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 9, 2018 Share Posted August 9, 2018 Try this: (defun c:foo (/ a l2k l2s x) ;; RJP » 2018-08-09 ;; Subtract one layer from another keeping pieces separate (defun _x (s) (cond ((= 'pickset (type s)) (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s))))) ) (cond ((and (setq l2k (_x (ssget "_x" '((0 . "3dsolid,region") (8 . "~bolts"))))) (setq l2s (_x (ssget "_x" '((0 . "3dsolid,region") (8 . "bolts"))))) ) (foreach y l2s (if (vlax-write-enabled-p y) (foreach x l2k (cond ((vlax-write-enabled-p x) (setq a (vla-copy y)) (vla-boolean x acsubtraction a))) ) ) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
pizarro Posted August 9, 2018 Author Share Posted August 9, 2018 PERFECT...! This is what I needed. Thank you very much. Quote Link to comment Share on other sites More sharing options...
pizarro Posted August 9, 2018 Author Share Posted August 9, 2018 PERFECT...! This is what I needed. Thank you very much. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 9, 2018 Share Posted August 9, 2018 Glad we got it sorted Quote Link to comment Share on other sites More sharing options...
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.