issue with hole table

issue with hole table

developer2F83JZ
Contributor Contributor
575 Views
1 Reply
Message 1 of 2

issue with hole table

developer2F83JZ
Contributor
Contributor

Hi All,

 

I got sample code to create a hole table from Below link

https://github.com/ADN-DevTech/Inventor-Training-Material/blob/master/Module%2015%20-%20Drawing%20Ad...

 

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

0 Likes
Accepted solutions (1)
576 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor
Accepted solution

try this. I changed the green part. and removed the red part from your code.

Dim 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.Item(1).SketchArcs.Item(1).Geometry.StartPoint.X)
    If Not oDrawingView.HasOriginIndicator Then
        Dim oDimIntent As GeometryIntent = Nothing
        Dim oPointIntent As PointIntentEnum = Nothing
        Dim oArc As SketchArc = oDrawingView.Sketches(1).SketchArcs(1)
        oPointIntent = PointIntentEnum.kStartPointIntent

        'If oPointIntent Is Nothing Then
        '    oPointIntent = oArc.Geometry.EndPoint
        '    int = PointIntentEnum.kEndPointIntent
        '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

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes