Message 1 of 7
3D arc geometry evaluator getstrokes "Type mismatch"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to implement the getstrokes feature from the API sample. I modified it a little so the input is the first 3D sketch and the first 3D arc in it.
I also have the same problem when trying it for 2D arcs (what I really need) but the sample was for 3D arcs thats why I use this to try and explain my problem.
This is the error message produced:
System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Inventor.CurveEvaluator.GetStrokes(Double FromParam, Double ToParam, Double Tolerance, Int32& VertexCount, Double[]& VertexCoordinates) at LmiRuleScript.Main() at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem) at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
SyntaxEditor Code Snippet
Dim partDoc As PartDocument partDoc = ThisApplication.ActiveDocument ' Have the user select a sketch entity. Dim selectObj As SketchEntity3D selectObj = PartDoc.componentDefinition.Sketches3D.Item(1).SketchArcs3D.Item(1)
''From here is nothing edited by me!
If selectObj Is Nothing Then On Error Resume Next Call partDoc.ComponentDefinition.ClientGraphicsCollection.Item("Test").Delete Call partDoc.GraphicsDataSetsCollection.Item("Test").Delete ThisApplication.ActiveView.Update Exit Sub End If ' Get the tolerance to approximate with. Dim tolerance As Double tolerance = Val(InputBox("Enter the chord height tolerance:", "Tolerance", "0.25")) ' Get the evaluator from the curve. Dim eval As CurveEvaluator eval = selectObj.Geometry.Evaluator ' Get the parameter extents. Dim startParam As Double Dim endParam As Double Call eval.GetParamExtents(startParam, endParam) Dim vertexCount As Long Dim vertexCoords() As Double Call eval.GetStrokes(startParam, endParam, tolerance, vertexCount, vertexCoords) ' Create a client graphics object. If one already exists, give the user ' the option of re-using it, or creating a new one. Dim graphics As ClientGraphics Dim graphicsData As GraphicsDataSets On Error Resume Next graphics = partDoc.ComponentDefinition.ClientGraphicsCollection.Item("Test") On Error Goto 0 If graphics Is Nothing Then graphics = partDoc.ComponentDefinition.ClientGraphicsCollection.Add("Test") graphicsData = partDoc.GraphicsDataSetsCollection.Add("Test") Else 'Dim answer As VbMsgBoxResult 'answer = MsgBox("Yes to add to existing graphics. No to create new graphics. Cancel to clean graphics and quit.", vbYesNoCancel + vbQuestion) If answer = vbNo Then On Error Resume Next graphics.Delete partDoc.GraphicsDataSetsCollection.Item("Test").Delete On Error Goto 0 graphics = partDoc.ComponentDefinition.ClientGraphicsCollection.Add("Test") graphicsData = partDoc.GraphicsDataSetsCollection.Add("Test") ElseIf answer = vbYes Then graphicsData = partDoc.GraphicsDataSetsCollection.Item("Test") ElseIf answer = vbCancel Then If Not graphics Is Nothing Then graphics.Delete partDoc.GraphicsDataSetsCollection.Item("Test").Delete ThisApplication.ActiveView.Update Exit Sub End If End If End If Dim coordSet As GraphicsCoordinateSet coordSet = graphicsData.CreateCoordinateSet(1) Call coordSet.PutCoordinates(vertexCoords) ' Create a graphics node. Dim node As GraphicsNode node = graphics.AddNode(1) ' Create a line strip using the calculated coordinates. Dim lineStrip As LineStripGraphics lineStrip = node.AddLineStripGraphics lineStrip.Coordinate= coordSet ThisApplication.ActiveView.Update
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2