- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've used the code samples shown here: http://adndevblog.typepad.com/manufacturing/2018/03/adding-modelfeaturecontrolframe-in-partdocument-...
and gotten them to work in the part environment. I'm trying to now adapt this code to work in an assembly, and running into confusing errors. Well... confusing to me (I'm pretty new to this)
I get the following error at the line in red below:
System.Runtime.InteropServices.COMException: 'The remote procedure call failed. (Exception from HRESULT: 0x800706BE)'
What is causing this? I can't seem to find the root cause.
Private Sub TEST_Click(sender As Object, e As EventArgs) Handles TEST.Click
Dim Doc As Document
Dim oDef As AssemblyComponentDefinition
Dim oTG As TransientGeometry
Dim dViewRepMgr As RepresentationsManager
Dim dWeldView As DesignViewRepresentations
InvApp = Marshal.GetActiveObject("Inventor.Application")
Doc = InvApp.ActiveDocument
oDef = Doc.ComponentDefinition
oTG = InvApp.TransientGeometry
dViewRepMgr = oDef.RepresentationsManager
dWeldView = dViewRepMgr.DesignViewRepresentations
Dim oFace As Face
oFace = InvApp.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face to attach leader")
Dim oAnnoPlaneDef As AnnotationPlaneDefinition
oAnnoPlaneDef = oDef.ModelAnnotations.CreateAnnotationPlaneDefinitionUsingPlane(oFace)
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = InvApp.TransientObjects.CreateObjectCollection
oLeaderPoints.Add(oTG.CreatePoint(5, 10, 0))
Dim oLeaderIntent As GeometryIntent
oLeaderIntent = oDef.CreateGeometryIntent(oFace)
oLeaderPoints.Add(oLeaderIntent)
Dim oLeaderDef As ModelLeaderNoteDefinition
oLeaderDef = oDef.ModelAnnotations.ModelLeaderNotes.CreateDefinition(oLeaderPoints, "Finally it works", oAnnoPlaneDef)
Dim oLeader As ModelLeaderNote
oLeader = oDef.ModelAnnotations.ModelLeaderNotes.Add(oLeaderDef)
End Sub
Solved! Go to Solution.