Equation (count based on length)

User avatar
Bryan O
Posts: 82
Joined: Wed Mar 24, 2021 7:34 am
Answers: 1
Location: Lowell MI
x 12
x 15

Equation (count based on length)

Unread post by Bryan O »

I'm not great with equations and I want to use one in pattern.
I was hoping that a math wizs out there could do it for me.
I want a variable pattern based on a variable length.
I have a variable length (48-96) and I want a pattern count to vary with a gap no less then 12 and no greater the 18.
Anyone have a solution for this?
User avatar
Glenn Schroeder
Posts: 1458
Joined: Mon Mar 08, 2021 11:43 am
Answers: 22
Location: southeast Texas
x 1651
x 2057

Re: Equation (count based on length)

Unread post by Glenn Schroeder »

Have you tried the "Up to reference" option in the pattern instead of "Spacing and instances"? That may eliminate the need for an equation.
"On the days when I keep my gratitude higher than my expectations, well, I have really good days."

Ray Wylie Hubbard in his song "Mother Blues"
User avatar
Frederick_Law
Posts: 1845
Joined: Mon Mar 08, 2021 1:09 pm
Answers: 8
Location: Toronto
x 1549
x 1402

Re: Equation (count based on length)

Unread post by Frederick_Law »

You might need to use IFF conditions.

Try RoundUp(Length / 12). You'll need to decide how to space from the end.
It will be more stable if you dimension the first from center of length. Instead of from end.
KevinC
Posts: 90
Joined: Fri Mar 12, 2021 10:14 am
Answers: 1
x 16
x 66

Re: Equation (count based on length)

Unread post by KevinC »

You'll need two global variables (gv) for count limits:
MaxCount = Part Length / Min gap
MinCount = Part Length / Max gap
Then another gv for the actual count to use, which is the integer portion of the average count:
ActualCount =int((MaxCount + MinCount)/2)

Part length must take into account any end starting offset to the first occurrance.

If you're starting at mid-part length, then you must determine if the actual count is even or odd:
ActualCountIsOdd = 2 * ((ActualCount/2) - (int(ActualCount/2)))
Because ActualCountIsOdd will be 1 for an odd count or otherwise zero, set the ActualCountIsEven to be the opposite:
ActualCountIsEven = iif(ActualCountIsOdd, 0,1)

Use ActualCountIsEven to set the starting offset from center (it will be either zero or 1/2 gap):
ActualGap = PartLength/ActualCount
MidLengthOffset = ActualGap / 2 * ActualCountIsEven

Also, for central starting, you'll need to adjust the ActualCount for both directions.
ActualCountSecondDir =int(ActualCount/2)
ActualCountFirstDir = ActualCount - ActualCountSecondDir
Check pattern seed for the 2nd direction.

I think that covers it.

Kevin
User avatar
jcapriotti
Posts: 1795
Joined: Wed Mar 10, 2021 6:39 pm
Answers: 29
Location: The south
x 1138
x 1942

Re: Equation (count based on length)

Unread post by jcapriotti »

We do this kind of stuff quite a bit as our products are parametric.

First create a pattern and use the "Up to reference" option. You can set the spacing offset for the last to a value or link it to the dimension for the first hole (I linked it). Set a quantity, doesn't matter what yet as you'll create an equation to control it later.
image.png
_
Next, create some Global Variables. I create one for the overall part length and link the dimension to it. then I create a variable to calculate the spacing between the first and last hole. Then another variable to calculate the count of holes.
image.png
You can build those directly on the dimensions (equations) but I prefer Global variables so I don't have to deal with the @sketch stuff in the equations which make them quite long sometimes.
Jason
User avatar
Rob
Posts: 128
Joined: Mon Mar 08, 2021 3:46 pm
Answers: 2
Location: Mighty Glossop, UK
x 788
x 207
Contact:

Re: Equation (count based on length)

Unread post by Rob »

Here's 3 examples of how I do it.
image.png
Specify a max value before we add another instance (can ignore minimum spacing)

Calculate the number required if we were to use the max value

Then use the INT function to convert the fractional result to an integer.

Note the check to see if we are at the exact boundary condition before (adding one) rounding up

It's always best to draw a little diagram to get your equation correct, especially if you've not done one for a while.

Something like this
image.png
Craig Schultz
Posts: 27
Joined: Fri Mar 19, 2021 10:04 am
Answers: 0
x 8
x 23

Re: Equation (count based on length)

Unread post by Craig Schultz »

You can modify the number of holes in equation, it'll suppress the pattern if you go outside of the 12-18" range. I don't know if this is what you're looking for, since it's hard to tell without a pic/example. I have another one set up with if statements and integer that can have a maximum of 18" spacing based on the overall length of the part.
Attachments
Spacing.SLDPRT
(60.69 KiB) Downloaded 73 times
User avatar
Jaylin Hochstetler
Posts: 387
Joined: Sat Mar 13, 2021 8:47 pm
Answers: 4
Location: Michigan
x 379
x 355
Contact:

Re: Equation (count based on length)

Unread post by Jaylin Hochstetler »

You can also use a Design Table. At that point you have all the power of Excel formulas at your finger tips. Attached is a file I used a design table with Excel formulas. This one didn't involve a pattern but you could still get some ideas off of it. Design Tables are EXTREMELY powerful.
Attachments
6801.zip
(4.24 MiB) Downloaded 51 times
A goal is only a wish until backed by a plan.
User avatar
SamSpade
Posts: 114
Joined: Tue Mar 23, 2021 3:34 pm
Answers: 2
Location: Montreal, QC
x 223
x 155

Re: Equation (count based on length)

Unread post by SamSpade »

You can use if / then statements in equations as others have mentioned. Nesting of these statements is possible, see the attached model. It may not be the most proficient way of doing it, but it'll get the job done to a certain extent.
Attachments
image.png
VARIABLE SPACING TEST.SLDPRT
(170.44 KiB) Downloaded 66 times
You miss 100% of the shots you don't take - Wayne Gretzky
Arthur McR
Posts: 8
Joined: Tue Mar 16, 2021 10:48 am
Answers: 0
Location: British Columbia, Canada
x 174
x 11

Re: Equation (count based on length)

Unread post by Arthur McR »

So, I've set up several different versions of this sort of thing depending on several factors. Is the spacing standardized and you need to get count and edge offset. Or is the edge offset standardized and the count and spacing needed to be determined.
The following is a .txt export from one such.
"Horz" = "D1@Sketch1"
"H_Max" = 18
"Offset" = 5
"Instances" = int( ("Horz" - "Offset"*2) / "H_Max")
"Spacing" = ("Horz" - "Offset"*2) / ("Instances" + 1)
Post Reply