- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I got sample code to create a hole table from Below link
I have an exception on CreateOriginIndicator to get GeometryIntent from sketchArc, could you please help me to resolve this issue. i have attached drawing file snip and also the exception.
Please advise me to resolve this, thanks in advance
Public Sub CreateHoleTables(ByVal app As Inventor.Application, ByVal Doc As DrawingDocument)
Doc = CType(app.ActiveDocument, DrawingDocument)
Dim oActiveSheet As Sheet = Doc.ActiveSheet
Dim oDrawingView As DrawingView
For Each oFrontView In Doc.ActiveSheet.DrawingViews
Doc.SelectSet.Select(oFrontView)
oDrawingView = Doc.SelectSet.Item(1)
MsgBox(oDrawingView.Sketches(1).SketchArcs(1).Geometry.StartPoint.X)
If Not oDrawingView.HasOriginIndicator Then
Dim oDimIntent As GeometryIntent = Nothing
Dim oPointIntent As Point2d = Nothing
Dim oArc As SketchArc = oDrawingView.Sketches(1).SketchArcs(1)
oPointIntent = oArc.Geometry.StartPoint
If oPointIntent Is Nothing Then
oPointIntent = oArc.Geometry.EndPoint
End If
oDimIntent = oActiveSheet.CreateGeometryIntent(oArc, oPointIntent)
oDrawingView.CreateOriginIndicator(oDimIntent)
End If
Dim oPlacementPoint As Point2d = Nothing
Dim oBorder As Inventor.Border = oActiveSheet.Border
If (oBorder IsNot Nothing) Then
oPlacementPoint = app.TransientGeometry.CreatePoint2d(oBorder.RangeBox.MinPoint.X, oBorder.RangeBox.MaxPoint.Y)
Else
oPlacementPoint = app.TransientGeometry.CreatePoint2d(0, oActiveSheet.Height)
End If
Dim oViewHoleTable As HoleTable = Nothing
oViewHoleTable = oActiveSheet.HoleTables.Add(oDrawingView, oPlacementPoint)
oPlacementPoint.X = oActiveSheet.Width / 2
Dim oFeatureHoleTable As HoleTable = oActiveSheet.HoleTables.AddByFeatureType(oDrawingView, oPlacementPoint, True, True, True, True, False, False, False)
Dim oModelDoc As Document = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oHoleF As HoleFeature = Nothing
If oModelDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
Dim oRefAssDoc As AssemblyDocument = CType(oModelDoc, AssemblyDocument)
Dim oAssDef As AssemblyComponentDefinition = oRefAssDoc.ComponentDefinition
If oAssDef.Features.HoleFeatures.Count > 0 Then
oHoleF = oAssDef.Features.HoleFeatures(1)
End If
ElseIf oModelDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim oRefPartDoc As PartDocument = CType(oModelDoc, PartDocument)
Dim oPartDef As PartComponentDefinition = oRefPartDoc.ComponentDefinition
If oPartDef.Features.HoleFeatures.Count > 0 Then
oHoleF = oPartDef.Features.HoleFeatures(1)
End If
End If
Next
End Sub
Solved! Go to Solution.