Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In the assembly drawing.
In the components (parts) the planes are described.
I want the rule to create a dimension between these planes.
Error displays all the time.
Sub Main() '[ Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument Dim oSheets As Sheets oSheets = oDoc.Sheets Dim oSheet As Sheet oSheets.Item(1).Activate oSheet = oDoc.ActiveSheet Dim nazwa As String = ThisDoc.FileName(False) 'without extension ZN = Len(nazwa) znn = ZN - 4 pref = Left(nazwa, ZN - 4) Dim oView1 As DrawingView oView1 = oSheet.DrawingViews.Item(1) ' 'Readys code for Creation of reference points for dimension placement Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim oPt1 As Point2d oPt1 = oTG.CreatePoint2d(oView1.Left + (oView1.Width / 3), oView1.Top - oView1.Height - 1) ' setting the component name Dim C0 As String C0 = pref & "-004:1" Dim C1 As String C1 = pref & "-005:2" Dim C2 As String C2 = pref & "-005:3" Dim viewModelDoc = ActiveSheet.View("WIDOK10").ModelDocument For Each oOcc00 As ComponentOccurrence In viewModelDoc.ComponentDefinition.Occurrences If oOcc00.Name = C0 Then For Each oOcc1 As ComponentOccurrence In viewModelDoc.ComponentDefinition.Occurrences 'MessageBox.Show(oOcc00.Name, "Title") If oOcc1.Name = C1 Then 'MessageBox.Show("Title", "Title") 'MessageBox.Show("C1", "Title") PlaceDIMinPart(oView1, oSheet, "Wym2", "WymN", oPt1, oOcc00, oOcc1) Exit For End If Next Exit For End If Next '] End Sub Private Function PlaceDIMinPart(oView As DrawingView, oSheet As Sheet, SFaceName As String, EFaceName As String, InsertPT As Point2d, oComp1 As ComponentOccurrence, oComp2 As ComponentOccurrence) '[ Dim aoFace1 As Inventor.FaceProxy aoFace1 = FindFace(oView, oSheet, SFaceName, oComp2) Dim aoFace2 As Inventor.FaceProxy aoFace2 = FindFace(oView, oSheet, EFaceName, oComp1) Dim oDrawCurves1 As Inventor.DrawingCurvesEnumerator oDrawCurves1 = oView.DrawingCurves(aoFace1) Dim aoFace2Edge1 As DrawingCurve aoFace2Edge1 = oDrawCurves1.Item(1) oDrawCurves2 = oView.DrawingCurves(aoFace2) Dim aoFace2Edge2 As DrawingCurve aoFace2Edge2 = oDrawCurves2.Item(1) '[ Dim startPoint2 As Point2d Dim endPoint2 As Point2d startPoint2 = aoFace2Edge2.StartPoint endPoint2 = aoFace2Edge2.EndPoint Dim startPoint1 As Point2d Dim endPoint1 As Point2d startPoint1 = aoFace2Edge1.StartPoint endPoint1 = aoFace2Edge1.EndPoint '] '[ 'Readys code for creation of general dimensions Dim oGeneralDims As GeneralDimensions oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions '] Dim oDim2 As GeneralDimension oDim2 = oGeneralDims.AddLinear(InsertPT, endPoint1 , endPoint2 , kHorizontalDimensionType) oDim2.Precision = 0 Dim oDim2Att As AttributeSet oDim2Att = oDim2.AttributeSets.Add("auto") '] End Function
Function FindFace(oView As DrawingView, oSheet As Sheet, FaceName As String, oComp As ComponentOccurrence) As Inventor.FaceProxy '[ Dim oAssemblyDoc As AssemblyDocument oAssemblyDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim oPartDoc As PartDocument = oComp.Definition.Document Dim oObjs As ObjectCollection oObjs = oPartDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", FaceName)
If oObjs.Count > 0 Then Dim oFace As Inventor.Face oFace = oObjs.Item(1) Dim oFaceProxy As Inventor.FaceProxy Call oComp.CreateGeometryProxy(oFace, oFaceProxy) FindFace = oFaceProxy End If '] End Function Error in underlined line:
EN:
The COM model object of type 'System.__ComObject' cannot be cast to the interface type 'Inventor.GeometryIntent'. This operation failed because a call to the QueryInterface method for the COM model component to retrieve an interface with IID identifier '{56B990B9-D25A-436F-A652-1D21EC739C57}' failed due to the following error: Such interface is not supported. (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). PL: Nie można rzutować obiektu modelu COM typu 'System.__ComObject' na typ interfejsu 'Inventor.GeometryIntent'. Ta operacja nie powiodła się, ponieważ wywołanie metody QueryInterface dla składnika modelu COM w celu uzyskania interfejsu o identyfikatorze IID '{56B990B9-D25A-436F-A652-1D21EC739C57}' nie powiodło się z powodu następującego błędu: Taki interfejs nie jest obsługiwany. (Wyjątek od HRESULT: 0x80004002 (E_NOINTERFACE)).
Solved! Go to Solution.