Author Topic: Holes in 3D solids  (Read 2796 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Guest
Holes in 3D solids
« on: January 07, 2011, 12:51:22 PM »
Does anyone have a program that will punch holes in solids? This is soemthing I have been thinking about trying to code but thought I'd check first.

Thanks

JCTER

  • Guest
Re: Holes in 3D solids
« Reply #1 on: January 07, 2011, 01:08:36 PM »
Does anyone have a program that will punch holes in solids? This is soemthing I have been thinking about trying to code but thought I'd check first.

Thanks
circle + presspull?
with the shortcut for presspull set to "pp" (in before Mav) it's pretty quick.

c;
*click center*
d;
1.25;
pp;
*click circle*
*drag-click or enter number*

I dunno if you can automate that much more than that, unless you have more complicated patterns that could save a bit of repetition.

A_LOTA_NOTA

  • Guest
Re: Holes in 3D solids
« Reply #2 on: January 07, 2011, 02:42:14 PM »

circle + presspull?
[/quote]

Thats the way I currently do it. But thought it would be faster if I could pick the point where I want the hole and give the dia.

kruuger

  • Swamp Rat
  • Posts: 637

mkweaver

  • Bull Frog
  • Posts: 352
Re: Holes in 3D solids
« Reply #4 on: January 10, 2011, 09:53:29 AM »
This is what I use:

Code: [Select]
Command: 3dhole
Hole size<9/16">

Select solids to receive the holes:
Select objects: Specify opposite corner: 2 found

Select objects:
Select linear objects for hole centerlines:
Select objects: Specify opposite corner: 3 found

Select objects:

Code: [Select]
(defun c:3h( / )(c:3dhole)) ;alias to 3dhole
(defun c:3dhole (/       ugetdist    olderr tolist ;Draw a round hole in selected 3D objects
centerlineobject    circle-elist circleent
ents       ss1    cmdecho      *error*
UndoGroup
)
  (defun *error*(msg)
    (if undogroup (command "undo" "e"))
    (if cmdecho (setvar "cmdecho" cmdedho))
    (princ msg)
    (princ)
    )
  (defun ToList (col / rtlist)     ;convert to a list
    (cond ;;We have a list
  ((listp col) col)
  ;;We have a string
  ((= 'STR (type col)) (vl-string->list col))
  ;;We have a selection set
  ((= 'PICKSET (type col))
   (vl-remove-if 'null
(vl-remove-if-not
   (function (lambda (e) (= 'ENAME (type e))))
   (apply 'append (ssnamex col))
)
   )
  )
  ;;We have a variant array
  ((and (= 'variant (type col))
(<= 8192 (vlax-variant-type col))
   )
   (vlax-safearray->list (vlax-variant-value col))
  )
  ;;We have a collection object
  ((not (vl-catch-all-error-p
  (vl-catch-all-apply 'vla-get-count (list col))
)
   )
   (progn (vlax-for item col (setq rtlist (cons item rtlist)))
  (reverse rtlist)
   )
  )
    )
  )
  (defun ugetdist (     ;getdist with a default
   default     ;default value
   prmpt     ;prompt
   /     ;end of formal arguments
   temp     ;
  )     ;end of local variable list
    (setq
      temp (getdist
     (strcat
       (if (and prmpt (= 'str (type prmpt)))     ;end and
prmpt
"\nDistance"
       )     ;end if valid prmpt?
       "<"
       (if (and default
(or (= 'real (type default)) (= 'int (type default)))
    ;end or
   )     ;end and
(rtos default)
""
       )     ;end if valid default?
       ">"
     )     ;end strcat
   )     ;end getdist
    )     ;end setq
    (if temp
      temp
      default
    )
  )
  (setq olderr *ERROR*)
  (defun *ERROR* (msg) (setq *error* olderr) (princ msg))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;Begin main 3dhole routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (if bolt:hole
    nil
    (if (setq bolt:hole (getcfg "AppData/alascad/bolt:hole"))
      (if (= "" bolt:hole)
(setq bolt:hole (/ 13 16.0))
(setq bolt:hole (distof bolt:hole 2))
      )
    )
  )
  (setq bolt:hole (ugetdist bolt:hole "Hole size"))
  (princ "\nSelect solids to receive the holes:")
  (cond
    ;;select the objects to receive the holes
    ((or (null (setq ss1 (ssget '((0 . "3DSOLID")))))
(= 0 (length (setq ents (tolist ss1))))
     )
     (princ "\nNo solids selected ")
    )
    ;;select objects for the centerlines
    ((null (setq CenterlineObjects
  (setq temp (prompt
       "Select linear objects for hole centerlines: "
     )
ss2  (ssget
       '((0
  .
  "circle,ARC,line,LWPOLYLINE,polyline,spline"
)
)
     )
  )
   )
     )
     (princ "\No centerline object selected.")
    )
    ;;we're ready, let's do it!
    (T
     (setq
       cmdecho (getvar "cmdecho")
       UndoGroup T
       )
     (setvar "cmdecho" 0)
     (command "Undo" "be")
     (mapcar
       (function
(lambda (CenterLineObject)
   (mapcar (function
     (lambda (3dsolid)
       (if (or (null (setq circle-elist
    (entmake (list '(0 . "CIRCLE")
   '(8 . "0")
   '(10 0 0 0)
   (cons 40 (/ bolt:hole 2.0))
     )     ;end entity list for circle
    )     ;end entmake
     )     ;end setq
       )     ;end null - no circle created
       (null (setq CircleEnt (entlast)))
   )
(princ "\n3Dhole routine unable to create hole.")
(progn (command "._sweep" CircleEnt "" CenterlineObject)
(command "subtract" 3dsolid "" (entlast) "")
)     ;end progn - run the sweep command
       )     ;end if circle created to sweep
     )     ;end lambda
   )     ;end function
   ents     ;list of solid objects for holes
   )     ;end mapcar
)
       )
           (tolist ss2)
     )
     (command "undo" "e")
     (setq undogroup nil)
     (setvar "cmdecho" cmdecho)
    )     ;end T
  )     ;end cond
  (princ)
)     ;end c:3dhole