Equation (count based on length)
Equation (count based on length)
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?
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?
- Glenn Schroeder
- Posts: 1522
- Joined: Mon Mar 08, 2021 11:43 am
- Location: southeast Texas
- x 1759
- x 2132
Re: Equation (count based on length)
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"
Ray Wylie Hubbard in his song "Mother Blues"
- Frederick_Law
- Posts: 1948
- Joined: Mon Mar 08, 2021 1:09 pm
- Location: Toronto
- x 1638
- x 1471
Re: Equation (count based on length)
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.
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)
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
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
- jcapriotti
- Posts: 1869
- Joined: Wed Mar 10, 2021 6:39 pm
- Location: The south
- x 1214
- x 1999
Re: Equation (count based on length)
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.
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.
Jason
Re: Equation (count based on length)
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
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
-
- Posts: 28
- Joined: Fri Mar 19, 2021 10:04 am
- x 8
- x 22
Re: Equation (count based on length)
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 121 times
- Jaylin Hochstetler
- Posts: 387
- Joined: Sat Mar 13, 2021 8:47 pm
- Location: Michigan
- x 380
- x 355
- Contact:
Re: Equation (count based on length)
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 76 times
A goal is only a wish until backed by a plan.
Re: Equation (count based on length)
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
-
- VARIABLE SPACING TEST.SLDPRT
- (170.44 KiB) Downloaded 117 times
You miss 100% of the shots you don't take - Wayne Gretzky
-
- Posts: 8
- Joined: Tue Mar 16, 2021 10:48 am
- Location: British Columbia, Canada
- x 174
- x 11
Re: Equation (count based on length)
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)
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)