Page 1 of 1
Equation (count based on length)
Posted: Wed Apr 14, 2021 11:18 am
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?
Re: Equation (count based on length)
Posted: Wed Apr 14, 2021 11:44 am
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.
Re: Equation (count based on length)
Posted: Wed Apr 14, 2021 11:56 am
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.
Re: Equation (count based on length)
Posted: Wed Apr 14, 2021 12:29 pm
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
Re: Equation (count based on length)
Posted: Wed Apr 14, 2021 1:05 pm
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.
_
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.
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.
Re: Equation (count based on length)
Posted: Wed Apr 14, 2021 1:59 pm
by Rob
Here's 3 examples of how I do it.
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
Re: Equation (count based on length)
Posted: Wed Apr 14, 2021 2:56 pm
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.
Re: Equation (count based on length)
Posted: Thu Apr 15, 2021 8:22 am
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.
Re: Equation (count based on length)
Posted: Thu Apr 15, 2021 1:13 pm
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.
Re: Equation (count based on length)
Posted: Thu Apr 15, 2021 2:08 pm
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)