internal rule not working as external rule (revisiontables.item)

internal rule not working as external rule (revisiontables.item)

c.neutschK4ZB6
Explorer Explorer
405 Views
3 Replies
Message 1 of 4

internal rule not working as external rule (revisiontables.item)

c.neutschK4ZB6
Explorer
Explorer

I got a problem with an external rule. That rule worked fine as internal rule, but now there's a failure at one expression

 

Dim oApp As Application
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oRevTable As RevisionTable
Dim myPoint As Inventor.Point2d
oApp = ThisApplication
oDoc = ThisDoc.Document
oSheet = oDoc.ActiveSheet
oRevTable = oSheet.RevisionTables.Item(1)

If oSheet.RevisionTables.Count = 0 Then
    MsgBox("There is no RevisionTable on this sheet.")
	Exit Sub
End If

Dim PointX As Double
Dim PointY As Double
Dim SizeX As Double
Dim SizeY As Double

SizeX = oRevTable.RangeBox.MaxPoint.X - oRevTable.RangeBox.MinPoint.X
SizeY = oRevTable.RangeBox.MaxPoint.Y - oRevTable.RangeBox.MinPoint.Y
PointX = PointX-SizeX
PointY = PointY

myPoint = oApp.TransientGeometry.CreatePoint2d(PointX, PointY)
oRevTable.Position = myPoint

 This is the failure text:

 

System.ArgumentException: Falscher Parameter. (Ausnahme von HRESULT: 0x80070057 (E_INVALIDARG))
bei System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
bei Inventor.RevisionTables.get_Item(Object Index)
bei ThisRule.Main()
bei Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
bei iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

0 Likes
Accepted solutions (1)
406 Views
3 Replies
Replies (3)
Message 2 of 4

theo.bot
Collaborator
Collaborator
Accepted solution

place this line after the check if there is a revision table. 

 

oRevTable = oSheet.RevisionTables.Item(1) 

 

Message 3 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @c.neutschK4ZB6 

 

In addition to the previous suggestion you could use a Try/Catch statement here.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oApp As Application
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oRevTable As RevisionTable
Dim myPoint As Inventor.Point2d
oApp = ThisApplication
oDoc = ThisDoc.Document
oSheet = oDoc.ActiveSheet

Try 
	oRevTable = oSheet.RevisionTables.Item(1)
Catch 
    MsgBox("There is no RevisionTable on this sheet.",,"iLogic")
	Exit Sub
End Try

Dim PointX As Double
Dim PointY As Double
Dim SizeX As Double
Dim SizeY As Double

SizeX = oRevTable.RangeBox.MaxPoint.X - oRevTable.RangeBox.MinPoint.X
SizeY = oRevTable.RangeBox.MaxPoint.Y - oRevTable.RangeBox.MinPoint.Y
PointX = PointX-SizeX
PointY = PointY

myPoint = oApp.TransientGeometry.CreatePoint2d(PointX, PointY)
oRevTable.Position = myPoint

 

EESignature

0 Likes
Message 4 of 4

c.neutschK4ZB6
Explorer
Explorer

Yeah guys... that's the clue. 

Now everything works fine. Don't know, why I didnt't recognize, that there was no revisiontable on drawing.

0 Likes