Drawing screw holes with a max dim on center

Drawing screw holes with a max dim on center

Anonymous
Not applicable
1,703 Views
13 Replies
Message 1 of 14

Drawing screw holes with a max dim on center

Anonymous
Not applicable

Hello,

 

AutoCAD 2016

 

I am currently in the process of drawing a few products parametrically. I have a "frame" that has mounting holes a set distance from each end both vertically and horizontally. I want to add screw holes based on being no more than x" apart.

 

Can this be accomplished in the parametric? If not, would VBA (decent excel experience) or LISP be the best way to accomplish this?

 

One other question, does SNAP FROM work in macros in 2016? I have "mixed" results with it.

 

Jeff

0 Likes
Accepted solutions (1)
1,704 Views
13 Replies
Replies (13)
Message 2 of 14

john.uhden
Mentor
Mentor

Is it just one row of holes, or perhaps multiple as in an array?  Do you draw (or want to have drawn) a line for the centerline of the holes?  Is the alignment more complicated as in following the path of a polyline?  Is the hole diameter always the same?  I am wondering if the spacing is relative to the hole diameter.

I am picturing a piano hinge.

John F. Uhden

0 Likes
Message 3 of 14

Anonymous
Not applicable

John,

 

Just a straight row/column of circles. I have the 1st and the last hole locations.

 

get the length between the 2 holes

  • spaces = divide length by 8, round up or add 1.
  • spacing = divide length by spaces
  • copy the 1st hole relative to its location + spacing * space for the number of spaces -1

I do not want to draw a line for the centers. The path is a straight line, horizontal or vertical. Hole diameter, per parametric drawing, will not change and is independent of spacing. As long as the holes are not staggered the piano hinge works if I was trying to figure hole spacing when I had a fixed location for the end holes. I am thinking of it as a piece of glazing stop that needs to be punched.

 

Looks like I need to do this in VBA or LISP, posted to make sure I'm not missing a simpler solution.

 

Thanks for your time.

 

Jeff

 

FORUM.jpg

 

 

 

 

0 Likes
Message 4 of 14

john.uhden
Mentor
Mentor

Would you prefer to:

A) Have it ask for the hole diameter and pick the first and last center points,

  or

B) Have you select the first and last circles and get the diameter from them (presuming the same size)?

 

Do you mean if the distance between holes is 40, then there are 5+1=6 spaces?

Also 6 spaces for a distance of 41 through 47, but 6+1=7 spaces for a distance of 48?

John F. Uhden

0 Likes
Message 5 of 14

Anonymous
Not applicable

John,

 

B - Pick the 1st circle then end circle, using the properties of either circle.

 

In the case of a distance of 40, I would have to check for a remainder of zero in the division before adding 1.

 

 

0 Likes
Message 6 of 14

Anonymous
Not applicable

John,

 

B - Pick the 1st circle then end circle, using the properties of either circle.

 

In the case of a distance of 40, I would have to check for a remainder of zero in the division before adding 1.

SAMPLE.jpg

 

 

 

 

0 Likes
Message 7 of 14

Anonymous
Not applicable

John,

 

B - Pick the 1st circle then end circle, using the properties of either circle.

 

In all the cases, I would have to check for a remainder of zero in the division before adding 1.  (so 40 would be 5 spaces, 48 6 spaces, etc.)

 

 

Here is what I am looking for in the case of a length of 41 or 47

SAMPLE.jpg

 

Jeff

 

 

 

0 Likes
Message 8 of 14

john.uhden
Mentor
Mentor

Ah, so if d is distance from first to last, then

 

(setq space (+ (/ d 8.0)(if (> (rem d 8) 0) 1 0)))

 

And just to confirm, "space" is the distance between centers, not the distance between holes, right?

 

John F. Uhden

0 Likes
Message 9 of 14

john.uhden
Mentor
Mentor

I think I got that wrong.  Try:

 

    (setq spaces (+ (fix (/ d 8.0))(if (> (rem d 8) 0) 1 0)))
    (setq space (/ d spaces))

John F. Uhden

0 Likes
Message 10 of 14

john.uhden
Mentor
Mentor
Accepted solution

I hope I got this right  (attached).

John F. Uhden

Message 11 of 14

Anonymous
Not applicable

John,

 

I appreciate your effort and will try this out in the morning.

 

Thank you.

Jeff

0 Likes
Message 12 of 14

john.uhden
Mentor
Mentor
I forgot to add (vl-load-com) at the top of the function. Please add it,
say just before (defun *error* ...)

John F. Uhden

0 Likes
Message 13 of 14

Anonymous
Not applicable

Done,

 

Thank you again for your help, gonna sit down and try to understand this over the weekend.

 

Happy Holidays!!

 

Jeff

0 Likes
Message 14 of 14

john.uhden
Mentor
Mentor
Happy Holidays to you too, OR ELSE!!

John F. Uhden

0 Likes