Jump to content

Subtract of layers


pizarro

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

Dear Ronjonp, keep converting the elements into one. Is it possible to keep the elements without becoming one after the subtraction?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

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