Guten Tag allerseits. Wir probieren, einen Punkt in einem Skizzen Block zu platzieren und später auch zu pattern. Es funktioniert alles gut bis zur zweitletzten Linie. Von da geht dann nichts mehr. Wir haben probiert, den gleichen Syntax zu brauchen wie die Feature Patterns brauchen, aber funktioniert leider nicht.
' Goal: to place a series of points within a block and then create patterns based on number per row' Algorithm:' 1: Check if block is created. If so, call it up, if not, create it.' 2: Ask user for number of rows' 3: Use loop to handle 3a through 3c' 3a: Ask user for number per row' 3b: Create first point in each row.' 3c: Pattern each row
' Create a reference to the part document.' This assumes a part document is active.
Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument
'' Create new sketch block.'Dim ActiveBlock As SketchBlockDefinition' ActiveBlock = partDoc.ComponentDefinition.SketchBlockDefinitions.Add("Point Block")
'' Or
' Reuse existing sketch block.
Dim ActiveBlock As SketchBlockDefinition
ActiveBlock = partDoc.ComponentDefinition.SketchBlockDefinitions.Item("Point Block")
' Get a reference to the SketchPoints collection.
Dim points As Inventor.SketchPoints = ActiveBlock.SketchPoints
Dim lines As Inventor.SketchLines = ActiveBlock.SketchLines
' Get a reference to the transient geometry object.
Dim transGeom As TransientGeometry
transGeom = ThisApplication.TransientGeometry
' Create X Axis
line1 = lines.AddByTwoPoints(transGeom.CreatePoint2d(-1, 0), transGeom.CreatePoint2d(1, 0))
' Get a reference to the GeometricConstraints collection. 'Dim geomConstraints As Inventor.GeometricConstraints 'geomConstraints = ActiveBlock.GeometricConstraints '
'' Ground axis'geomConstraints.AddHorizontal(line1)
Dim Spacing As Double
Spacing = Val(InputBox ("Enter the point spacing:", "Spacing", "1"))
Dim RowQty As Integer
RowQty = Val(InputBox ("Enter the number of rows:", "Number of Rows", "2")) - 1
Dim RowQuantities(RowQty) As Integer
Dim pointArray(RowQty) As Inventor.SketchPoint
For i = 0 To RowQty ' should handle all activities for a given row
j = i + 1
RowQuantities(i) = Val(InputBox ("Enter the Number in Row " & j & ":", "Number in Row" & j , "4"))
x = -(RowQuantities(i) - 1 ) / 2
y = j * Spacing
pointArray(i) = points.Add(transGeom.CreatePoint2d( -(RowQuantities(i) - 1 ) / 2 * Spacing, i * Spacing), True)
' MessageBox.Show("Row " & i+1 & " points: " & -(RowQuantities(i) - 1 ) / 2 * Spacing & ", " & i * Spacing, "Point Result") 'Show results for testing purposes'
>> HIER FUNKTIONIERTS NICHT MEHR 'Pattern point generated by pointArray(i) along line1
Next
------------------
Grüsse aus Calgary, Alberta, Canada
Andy
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP