Inventor rectangular equation

Inventor rectangular equation

Anonymous
Not applicable
1,287 Views
14 Replies
Message 1 of 15

Inventor rectangular equation

Anonymous
Not applicable

Dear all,

 

We are struggling on how to create something that seems kinda simple in concept but cannot find a way to figure it out.

The idea is to create a curve that later on I will use to build a rectangular pattern. Thats the simple idea, the stupid stuck part is the equation to follow.

 

Please find attached the self explanatory picture. I want to create a squared pattern following the simple rules of 1 1 2 2 3 3 4 4 ... times a single value.

 

Equations seems to be simple or I might be very stupid but cannot replicate it doing a pattern following that rule.

 

The key point is that we need to do hundreds of "coils" so by hand can be done but its not worth.

 

Any idea?

 

Thank you so much.

 

Yours,

Accepted solutions (2)
1,288 Views
14 Replies
Replies (14)
Message 2 of 15

Owner2229
Advisor
Advisor

Hi, if the curve has always the same shape, just different dimensions then I believe you want to use it as a template.

The simpliest solution is to drive the dimensions by the first dimension (23.813).

Here is how:

* use everithing here without the quotation marks

1) Open the first dimension (23.813) for editing (double-click)

2) Above you'll see the name of the dimension. Something like "d0" or "d1" etc. Remember it.

3) Open the second dimension for editing (the one you want to have the same value as the first one)

4) Write in the name of the first dimension. E.g. If the first dimension's name is "d0" then you'll write "=d0"

5) Open the third dimension (the one you want it's value to be double of the first one)

6) Write in "=d0 * 2"

7) Go on for the rest of your dimensions...

 

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 15

Anonymous
Not applicable

Hi!,

 

Thank you so much for the reply.

 

However, I think that doesnt fit our needs, as we are dealing a tremendous huge size. We though to do it but that way, but it will be not worth, given the dimmensions.

 

For example, we start with 25 mm as the first "template" as you mention, but given that we need to cover an area of 3000x3000 mm, that will mean that we need to do it at least 50 times in order to cover the whole region.

 

Do you think there will be a simpler way?


Thank you so much for your help!

 

Yours,

0 Likes
Message 4 of 15

Owner2229
Advisor
Advisor

Hi, Im not sure we're on the same wave.

You need this "shape" in about 50 different sizes, right?

The smallest starts at about 25 mm and the biggest is 3000 mm, still right?

So, the purpose of this template is that once you set up the dimension, you can simply change the value "23.813" and it will automaticly rescale all the lines.

 

Or you need only this one "shape" to have different amount of lines (8 now)?

Im not sure if you want to scale this "shape" with the same amount of lines, or add new lines to the "shape".

 

Or you already have this shape with more lines and you want to set it's line's dimmensions to scalable?

 

We can do any of it or all of it at once, just let me know what it is.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 15

Anonymous
Not applicable

Hi there! Sorry for the misunderstanding, I think we are not in the same wave. What I mean is to recreate the same shape filling with lines following the pattern rule, which is exponential.

 

I dont want just to scale, i just want to add as many lines (to recreate later on a curve to do a rectangular pattern) as I need to fiil in certain area, which usually is huge.

 

I was looking for a simple way to do so, instead of adding all thee lines manually... which is a pain.

 

Thank you so much!

 

TIP: I have added a more evolved solution to see the idea behind.... see attached

0 Likes
Message 6 of 15

Owner2229
Advisor
Advisor

Oh, I see now... It will be best to do so by a rule then.

Are the angles always gona be the same (60° and 120°)? Or will they vary as well?

Im just trying to get all input variables, so I can base the new rule on them.

So if there are any other specifications or conditions, then let me know.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 7 of 15

Anonymous
Not applicable

HI there!

 

Thanks for your fast reply!

 

Yes, angles would be always the same. We can always mirror just in case.

 

Thank you!

0 Likes
Message 8 of 15

Owner2229
Advisor
Advisor

And the size of the smallest (first) line will always be "23.813" ?

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 9 of 15

Anonymous
Not applicable

It could be 16, 19,25, any value, but usually is the base one all the others will follow.

0 Likes
Message 10 of 15

Owner2229
Advisor
Advisor

So, here below is my first attempt. It might need some tweaks, but as first example it should do.

1) In an part create new sketch and open it for editing

2) Create new iLogic rule and paste there this rule. (you can add new iLogic rule under "Manage" > "Add rule")

3) Run the rule.

4) It will ask for the size of the area that has to be filled and size of the first line.

5) It will generate the lines and close the sketch.

 

Let me know what else you want it to do or what you want to change on the current operations.

 

 

Sub Main()
    Dim oDoc As Document = ThisApplication.ActiveDocument
    Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
    If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        oSketch = ThisApplication.ActiveEditObject
    Else
        MsgBox("Run this rule from an open sketch, please.")
        Exit Sub
    End If
    oArea = InputBox("Please enter the size of the area to be filed.", "Area input", 100)
    If oArea = 0 Then
        Exit Sub
    End If
    OrigSize = InputBox("Please enter the size of the base (first, smallest) line.", "Area input", 23.813)
    If OrigSize = 0 Then
        Exit Sub
    End If
    CreateLines()
    oSketch.ExitEdit
    InventorVb.DocumentUpdate()
End Sub

Private Amount As Integer
Private oArea As Double
Private OrigSize As Double
Private oSketch As Sketch

Private Sub CreateLines()
    Dim PI As Double = 4 * Atan(1)
	Dim TG As TransientGeometry = ThisApplication.TransientGeometry
	oArea = oArea * 0.1 'cm to mm
	OrigSize = OrigSize * 0.1 'cm to mm
	oSize = OrigSize
	Dim PosX As Double = oSize
	Dim PosY As Double = 0
	Dim Amount As Integer = Floor(oArea / (oSize * 2.5))
	Dim Point1 As Point2D = TG.CreatePoint2d(0, 0)
	Dim Point2 As Point2D
	For i = 1 To Amount
		Point2 = TG.CreatePoint2d(PosX, PosY)
		AddLine(Point1, Point2)
		Point1 = Point2
		PosX = PosX - (oSize * Sin(PI * 0.16667))
		PosY = PosY + (oSize * Cos(PI * 0.16667))
		Point2 = TG.CreatePoint2d(PosX, PosY)
		AddLine(Point1, Point2)
		oSize = oSize + OrigSize
		Point1 = Point2
		PosX = PosX - oSize
		PosY = PosY
		Point2 = TG.CreatePoint2d(PosX, PosY)
		AddLine(Point1, Point2)
		Point1 = Point2
		PosX = PosX + (oSize * Sin(PI * 0.16667))
		PosY = PosY - (oSize * Cos(PI * 0.16667))
		Point2 = TG.CreatePoint2d(PosX, PosY)
		AddLine(Point1, Point2)
		oSize = oSize + OrigSize
		Point1 = Point2
		PosX = PosX + oSize
		PosY = PosY
	Next
End Sub

Private Sub AddLine(PointA As Point2D, PointB As Point2D)
    oSketch.SketchLines.AddByTwoPoints(PointA, PointB)
End Sub

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 11 of 15

Anonymous
Not applicable

Hi there,

Thank you so much!. Basically it works, although it still not appropiate for the rectangular pattern. We need to lock them and make all of them also like in a loop, so the whole curve is considered as one continuos one. This will allow the pattern to work through the curve.

 

Also, as you can see from the previous picture, pattern doesnt fit so nicely into a round, so, we are trying to modify the code to make it fill the internal part of a piece.

 

Thank you, if you suggest how to make it fixed within the code we will not need to do it manually, just like in a spline.

 

TIP: We can do it manually by running sketch doctor to combine points in just one.

 

Yours,

0 Likes
Message 12 of 15

Owner2229
Advisor
Advisor
Accepted solution

Hi, it is now one continuous line and I have added the constrains in the rule. However, the last point of the last line is NOT grounded, so you still have to do it manualy. I couldn't find the right way to add the constrain to the point. I have aslo modifed the scale ratio, so it could fit in the area a bit better.

You can adjust the ratio by changing the number "2.8". Highter number means less lines.

Currenty it is runnig by one round of the "shape" per one loop (it will create 4 lines per loop).

It might be possible to change it so it would run e.g. 1,5 rounds of the "shape" if it would fit better (create 1 line per loop).

It should lead to tighter fit. Let me know if cuting the "shape" on parts is an option and I'll rewrite it.

 

Sub Main()
    Dim oDoc As Document = ThisApplication.ActiveDocument
    Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
    If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        oSketch = ThisApplication.ActiveEditObject
    Else
        MsgBox("Run this rule from an open sketch, please.")
        Exit Sub
    End If
	Try
        oArea = InputBox("Please enter the size of the area to be filed.", "Area input", 100)
        If oArea = 0 Then
            Exit Sub
        End If
        OrigSize = InputBox("Please enter the size of the base (first, smallest) line.", "Area input", 23.813)
        If OrigSize = 0 Then
            Exit Sub
        End If
	Catch
		Exit Sub
	End Try
    CreateLines()
    oSketch.ExitEdit
    InventorVb.DocumentUpdate()
End Sub

Private Amount As Integer
Private oArea As Double
Private oLine As SketchLine
Private OrigSize As Double
Private oSketch As Sketch

Private Sub CreateLines()
    Dim PI As Double = 4 * Atan(1)
	Dim TG As TransientGeometry = ThisApplication.TransientGeometry
	oArea = oArea * 0.1 'cm to mm
	OrigSize = OrigSize * 0.1 'cm to mm
	oSize = OrigSize
	Dim PosX As Double = oSize
	Dim PosY As Double = 0
	Dim Amount As Integer = Floor(oArea / (oSize * 2.8))
	Dim Point1 As Point2D = TG.CreatePoint2d(0, 0)
	Dim Point2 As Point2D
	For i = 1 To Amount
		Point2 = TG.CreatePoint2d(PosX, PosY)
		Try
			oLine = oSketch.SketchLines.AddByTwoPoints(oLine.EndSketchPoint, Point2)
		Catch
			oLine = oSketch.SketchLines.AddByTwoPoints(Point1, Point2)
		End Try
		oSketch.GeometricConstraints.AddGround(oLine)
		PosX = PosX - (oSize * Sin(PI * 0.16667))
		PosY = PosY + (oSize * Cos(PI * 0.16667))
		Point2 = TG.CreatePoint2d(PosX, PosY)
		AddLine(Point2)
		oSize = oSize + OrigSize
		PosX = PosX - oSize
		PosY = PosY
		Point2 = TG.CreatePoint2d(PosX, PosY)
		AddLine(Point2)
		PosX = PosX + (oSize * Sin(PI * 0.16667))
		PosY = PosY - (oSize * Cos(PI * 0.16667))
		Point2 = TG.CreatePoint2d(PosX, PosY)
		AddLine(Point2)
		oSize = oSize + OrigSize
		PosX = PosX + oSize
		PosY = PosY
	Next
End Sub

Private Sub AddLine(PointB As Point2D)
	oLine = oSketch.SketchLines.AddByTwoPoints(oLine.EndSketchPoint, PointB)
	oSketch.GeometricConstraints.AddGround(oLine)
End Sub

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 13 of 15

Anonymous
Not applicable

Dear Owner, 


Everything fits OK! Thank you. Cutting the shape into pieces so we could fit on different layouts will be great. Thank you so much!

 

For the grounding part, it is not required thanks!


I will mark it as solved!, as the tweaks we need know are small ones.

 

Thank you so much again!

0 Likes
Message 14 of 15

Owner2229
Advisor
Advisor
Accepted solution

Hi, here below is the updated code. I needed to adjust the ratio again (now it's "0.7473"). I have tested it up to 5000 mm wide area.

 

Sub Main()
    Dim oDoc As Document = ThisApplication.ActiveDocument
    Dim oCD As ComponentDefinition = oDoc.ComponentDefinition
    If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        oSketch = ThisApplication.ActiveEditObject
    Else
        MsgBox("Run this rule from an open sketch, please.")
        Exit Sub
    End If
	Try
        oArea = InputBox("Please enter the size of the area to be filed.", "Area input", 1000)
        If oArea = 0 Then
            Exit Sub
        End If
        OrigSize = InputBox("Please enter the size of the base (first, smallest) line.", "Area input", 23.813)
        If OrigSize = 0 Then
            Exit Sub
        End If
	Catch
		Exit Sub
	End Try
    CreateLines()
    oSketch.ExitEdit
    InventorVb.DocumentUpdate()
End Sub

Private Amount As Integer
Private oArea As Double
Private oLine As SketchLine
Private OrigSize As Double
Private oSketch As Sketch

Private Sub CreateLines()
    Dim PI As Double = 4 * Atan(1)
	Dim TG As TransientGeometry = ThisApplication.TransientGeometry
	oArea = oArea * 0.1 'cm to mm
	OrigSize = OrigSize * 0.1 'cm to mm
	oSize = OrigSize
	Dim PosX As Double = oSize
	Dim PosY As Double = 0
	Dim Amount As Integer = Floor(oArea / (oSize * 0.7473))
	Dim Point1 As Point2D = TG.CreatePoint2d(0, 0)
	Dim Point2 As Point2D
	Dim Position As Integer = 1
	For i = 1 To Amount
		Select Case Position
		Case 1
			Point2 = TG.CreatePoint2d(PosX, PosY)
			Try
				oLine = oSketch.SketchLines.AddByTwoPoints(oLine.EndSketchPoint, Point2)
			Catch
				oLine = oSketch.SketchLines.AddByTwoPoints(Point1, Point2)
			End Try
			oSketch.GeometricConstraints.AddGround(oLine)
		Case 2
			PosX = PosX - (oSize * Sin(PI * 0.16667))
			PosY = PosY + (oSize * Cos(PI * 0.16667))
			Point2 = TG.CreatePoint2d(PosX, PosY)
			AddLine(Point2)
		Case 3
			oSize = oSize + OrigSize
			PosX = PosX - oSize
			PosY = PosY
			Point2 = TG.CreatePoint2d(PosX, PosY)
			AddLine(Point2)
		Case 4
			PosX = PosX + (oSize * Sin(PI * 0.16667))
			PosY = PosY - (oSize * Cos(PI * 0.16667))
			Point2 = TG.CreatePoint2d(PosX, PosY)
			AddLine(Point2)
			oSize = oSize + OrigSize
			PosX = PosX + oSize
			PosY = PosY
		End Select
		If Position = 4 Then Position = 1 Else Position = Position + 1
	Next
End Sub

Private Sub AddLine(PointB As Point2D)
	oLine = oSketch.SketchLines.AddByTwoPoints(oLine.EndSketchPoint, PointB)
	oSketch.GeometricConstraints.AddGround(oLine)
End Sub
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 15 of 15

Anonymous
Not applicable

Dear owner,


Thank you uso much!

 

Yours,

 

Morg

0 Likes