DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Macro for drilling holes, blind, through or tapped

Started by samdavo, May 05, 2013, 01:28:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

samdavo

Gents,
This concerns drilling holes in plates.
Diam 2R, depth say dpth,
( we can talk about 120deg drillends, and even thread later...) ...
 
I'm guessing there is a macro out there for this, at least for a simple cylindrical hole normal to the surface at a given point;
or if not, we are so close to it, it's not funny...

DL2P.d3m draws a line from a plane normal to that plane.
first point set = call it "pointmark" on surface;
second is the direction to the vertices of a hex bolt ( not important for a simple hole);
third completes the plane.  (all pretty normal for setting a plane);

and asks for length of line ( = dpth, probably negative, depending on direction of points 1,2,3, but read on)...
all we (collectively) would need would be a small increase in the line to clear the surface , or better still just  draw the line both +dpth and -dpth (so the surface becomes mid-plane, that way you wouldn't have to concentrate on how to choose points 2 and 3); this becomes the axis of the cylinder;

you enquire what diam, add a cylinder on that axis, subtract from the orig solid ( would it need a name?) 
presto, numero uno drilling operation underlay underlay.

PS It could be adapted to load, not a cylinder, but a short length of a cheapskate thread ( named to identify it?)  and hence you have a tapped hole.

(I haven't done much but suggest the mission sorry - although there is a sam-cheapskate-bolt out there available for anyone to use :) )
For discussion over a long distance beer.
cheers
sam 

samdavo

#1
ok. I've started it off with this "first draft"
I've simply added a few lines at the start and the end of pl2p.d3m;
in the middle it loads a symbol called "bolt with 2 handles"
you'll find a line of text there ...
"   'the following 12 lines inserted in a hurry, and need to be reviewed"

anyway, I fail to select the solid symbol once loaded, and fail to orient it normal to the surface as I wish. 

wORSE STILL , WHEN I TRY TO load the symbol (using Ctrl+F9) even without the macro, it doesn't want to load with the handles I set it (?)  And that could be the problem rather than the macro (?)

ok, I was trying to load that symbolic (cheapskate) threaded bolt as a symbol called "bolt with 2 handles"  at the TDC top dead centre of that saddle.  I haven't spent much time with it, and clearly the bolt doesn't end up where it's intended, lol.
(And after that I have to subtract the bolt from the solid I'm working with)
More work required,

(in the zoomed in version, you'll see the three points I selected. These are related to the boundingbox for the bolt symbol, not the handles I saved it with ??)

'Program: drillahole.d3m is based on pl2p.d3m (to draw a line perp to a plane)
'but then inserts a cylinder

'turns off ortho and angle constraint modes during macro

Dim X(3), Y(3), Z(3)

fixedstate = sys(152)
sys(152)=1 'change to fixed state

'save status of ortho and angle constraint modes
omode=sys(347)
acmode=sys(1024)

'turn off ortho and angle constraint modes
sys(347)=0
sys(1024 )= 0

user:
SetPoint "Set 3 points to define plane: " 3
If Sys(1) < 3 Then goto user

For i = 1 To 3
PointVal X(i) Y(i) Z(i) i
Next i
Sys(1) = 0


precision 15
'get input, use string input format so user can enter feet and inches if desired
input "enter magnitude (length) of the line: ", rz$
r=val(rz$)

if r = 0 then
message "error: no line length input provided."
end
end if

sys(80)=0

'draw a line at 0,0,0 of specified length
>line
{
<Pointxyz [0, 0, 0]
<Pointxyz [0, r, 0]
}

'the following 12 lines inserted in a hurry, and need to be reviewed
>SymbolLoad
{
  <Layer 0
  <Pointxyz [0,0,0]
  <Pointxyz [0,r,0]
  <Pointxyz [0,r,0]
  <Filename "BOLT with 2 handles.dcd"
  <Type 1
  <Scale 1
  <Reference 0
  <LoadAsBlock 0
  }

'select the line just drawn
getattr sys(9), type, select
putattr sys(9), type, 1

>SetHandle
{
<Pointxyz [0, 0, 0]
<Pointxyz [1, 0, 0]
<Pointxyz [0, 0, 1]
}

>move
{
<Pointxyz [X(1), Y(1), Z(1)]
<Pointxyz [X(2), Y(2), Z(2)]
<Pointxyz [X(3), Y(3), Z(3)]
}

'...



sys(1)=0
sys(152)= fixedstate 'restore to initial setting

'reset ortho and angle constraint modes
sys(347)=omode
sys(1024)=acmode

>SelectPrevious
{
}

End

samdavo

Here's the "bolt with two handles" that I was loading by the way.

I'm guessing (the way I say simply "load symbol bolt with 2 handles.dcd"  , i.e. without further clarification of path,  that it has to be in the same directory as the macro (?). 

But as I say, I can't even get the thing to load with correct orientation, even when I load it manually,  i.e.
a. I click Ctrl+F9
b. ask it to load "bolt with 2 handles.dcm" into the drwg
c. place a set of 3 handle

...
and it ignores the handles I set, and uses the corners of the bounding box ?
(sheesh - 2D was never like this lol) 

prl

Sam,

You need to save your bolt as a symbol with three handles or equivalently set three drawing handles and save the drawing. The sequence of the handles should be the  same three handles you will use when you load it.

Some rules and quirks.

Symbols like blocks will not let you do Boolean operations.

DesignCAD has a major flaw when load and/or merge drawings including symbols or blocks.  The file you load from disk becomes cached internally in the drawing.  The next time you attempt to read the file from your disk, it instead uses the cached version.  This presents a problem when you decide to update or improve the bolt drawing on your hard disk and then you reload it or insert some more using the macro or manually.  You'll go mad trying to figure out why you are getting your previous version even though you are specifically telling DC to load the one from your hard disk. 

samdavo

#4
Quote from: prl on May 06, 2013, 07:42:13 AM
Sam,

You need to save your bolt as a symbol with three handles or equivalently set three drawing handles and save the drawing. The sequence of the handles should be the  same three handles you will use when you load it.
prl, yes but, lol
that's what I swear I am doing !!!

I mean, I can load a 2D symbol into a 3D drawing, and whilst it is pretty meaningless,  at least it obeys the rule of handles being where you set them.

But with that bolt, no matter how many times I've tried, and how many versions I've saved with new names - at least six, I load it, and it wants to use the bounding box instead of the handles.

(might have to be tomorrow I tackle this - 1.00am, and I'm starting to wake up the household with cuss words lol.)
cheers 

PS If you could just give me back this bolt drawing with the handles set correctly it would be much appreciated -
handle 1 = just under the head at the junction with the unthreaded shaft, and on axis
handle 2 = end of bolt and on axis
handle 3 = one of the vertices of the hex head 

sorry bout this but I'm hitting my head against a brick wall here.
(and the damned thing wants to load with handles at the bounding box no matter what I do)
golly gee,  oh my hat , as my uncle used to say :)

samdavo

sorry x1000
"save as symbol" oops
and there are options for handles

you know I've never had to worry about that with 2D.
apologies.

prl

Sam,

May I suggest a different approach, combining two existing macros, one of which you already know.  Use pl2p.d3m macro to draw construction lines that represent your drill path.  Then use the cyl2.d3m to create cylinder solids,  see http://forum.designcad.com/index.php?topic=4533.msg27417#msg27417

Your final step is to subtract the cylinder solids from the plate.

samdavo

THanks, but I might also need some help to load up a symbol of a bolt which can be Solid Subtracted.
and that goes for a (cylinder +cone) drill bit as well ( 2 cents)
cheers
sam

(can't believe I didn't know how to save a symbol - still , as I say, I'm sure you didn't need to do anything but "save" in 2D, and handles were saved with it.  - maybe I'm wrong - no time now cheers )