Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Solid "cookie cutter" cut?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
hypersonic
888 Views, 3 Replies

Solid "cookie cutter" cut?

Does anyone have a routine that would allow you to cut out an odd shape from a solid with the profile of a polyline?

Not slice, as slice acts only in a plane.....

 

The goal would be to have all the pieces that are left, not subtract them out.....

 

Thanks!

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: hypersonic


@hypersonic wrote:

Does anyone have a routine that would allow you to cut out an odd shape from a solid with the profile of a polyline?

Not slice, as slice acts only in a plane.....

 

The goal would be to have all the pieces that are left, not subtract them out.....


There may be other and better ways, but this seems to do that, in minimal testing:

 

(defun C:TEST (/ s1 p minZ maxZ s2 s3 s4)
  (setq
    s1 (car (entsel "Select Solid to cut cookie out of: "))
    p (car (entsel "Select Polyline cookie outline: "))
  ); setq
  (vla-getboundingbox (vlax-ename->vla-object s1) 'minpt 'maxpt)
  (setq
    minZ (caddr (vlax-safearray->list minpt)); lowest Z coordinate of Solid
    maxZ (caddr (vlax-safearray->list maxpt)); highest
  )
  (command
    "_.change" p "" "_p" "_e" minZ ""; drop or raise Polyline to bottom of Solid
    "_extrude" p "" (- maxZ minZ) ""; extrude Polyline to height of Solid
  ); command
  (setq s2 (entlast))
  (command "_copy" s1 "" "@" "@"); another of the original Solid
  (setq s3 (entlast))
  (command "_copy" s2 "" "@" "@"); another of the extruded Polyline
  (setq s4 (entlast))
  (command
    "_subtract" s1 "" s2 ""; outer portion out of which 'cookie' is cut
    "_intersect" s3 s4 ""; inner 'cookie'
  ); command
); defun

 

It has nothing of the usual other stuff (error handling, entity-type selection control, etc.), and it doesn't take the Coordinate System(s) into account, and it depends on the User selecting a cookie shape that "qualifies" for the purpose [i.e. is presumably inside the extent of the Solid], and if you add entity-type selection control, you could enhance it to accept other object types as cookie shapes [e.g. Circles], and so on.  But see what you think of it as a starting point.

 

Unfortunately, Subtract and Intersect don't seem to have any option to retain source parts, the way Slice does, nor to be affected by the DELOBJ System Variable, the way Extrude is.  That's why the routine makes copies, and does the Subtract on one pair and the Intersect on the other.

Kent Cooper, AIA
Message 3 of 4
hypersonic
in reply to: Kent1Cooper

Awesome Kent! thank you so much!

 

Message 4 of 4
hypersonic
in reply to: hypersonic

I was going to attach a video for anyone that wanted to see what this function does.... But the forum does not allow videos apparently (.avi)  Anyways, good job Kent!!!! this solid slice by polyline or solid cookie cutter  is the best thing since sliced bread....

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost