Thicken feature in Sheet metal

Thicken feature in Sheet metal

piotrekdoro94
Advocate Advocate
229 Views
2 Replies
Message 1 of 3

Thicken feature in Sheet metal

piotrekdoro94
Advocate
Advocate

Hi, I'm using Inventor 2016 and I'm trying to create a vba form that would generate YConnectors. I've managed to draw the shape of the YConnector with surface bodies but I can't thicken them. Thera are three thicken features present (on lines 39, 43, 47) but only the first one of these will work. If I comment out thicken feature on line 39 then  the thicken command on line 43 will work, but the one on line 47 won't

 

Below there is a relevant code snippet:

 

Imports Inventor
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim InventorApp As Inventor.Application

        Try
            InventorApp = Marshal.GetActiveObject("Inventor.Application")
            MessageBox.Show("Connected To Inventor session")

        Catch ex As Exception
            MessageBox.Show("Failed to connect to inventor session")
        End Try

        If Not (InventorApp.ActiveDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then 'Switch document subtype to sheet metal
            InventorApp.ActiveDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
        End If

        Dim oPartDoc As PartDocument
        Dim oPartCompDef As SheetMetalComponentDefinition
        'Dim oPartCompDef As ComponentDefinition

        oPartDoc = InventorApp.ActiveDocument
        oPartCompDef = oPartDoc.ComponentDefinition

        Dim oThickenCollectorFaceCollection As FaceCollection
        Dim oThickenInletFaceCollection1 As FaceCollection
        Dim oThickenInletFaceCollection2 As FaceCollection

        Dim oThickenCollector As ThickenFeature
        Dim oThickenInlet1 As ThickenFeature
        Dim oThickenInlet2 As ThickenFeature

        oThickenCollectorFaceCollection = InventorApp.TransientObjects.CreateFaceCollection() 'Create face collection
        oThickenCollectorFaceCollection.Add(oPartCompDef.Features(1).SurfaceBodies(1).Faces(1)) 'Add collector surface to face collection
        oThickenCollector = oPartCompDef.Features.ThickenFeatures.Add(oThickenCollectorFaceCollection, Convert.ToDouble(CollectorThicknessTextBox.Text) / 10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, PartFeatureOperationEnum.kNewBodyOperation) 'Thicken collector

        oThickenInletFaceCollection1 = InventorApp.TransientObjects.CreateFaceCollection() 'Create face collection
        oThickenInletFaceCollection1.Add(oPartCompDef.Features(2).SurfaceBodies(1).Faces(1)) 'Add inlet 1 surface to face collection
        oThickenInlet1 = oPartCompDef.Features.ThickenFeatures.Add(oThickenInletFaceCollection1, Convert.ToDouble(InletThicknessTextBox.Text) / 10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, PartFeatureOperationEnum.kNewBodyOperation) 'Thicken inlet 1

        oThickenInletFaceCollection2 = InventorApp.TransientObjects.CreateFaceCollection() 'Create face collection
        oThickenInletFaceCollection2.Add(oPartCompDef.Features(3).SurfaceBodies(1).Faces(1)) 'Add inlet 1 surface to face collection
        oThickenInlet2 = oPartCompDef.Features.ThickenFeatures.Add(oThickenInletFaceCollection2, Convert.ToDouble(InletThicknessTextBox.Text) / 10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, PartFeatureOperationEnum.kNewBodyOperation) 'Thicken inlet 2

        oPartDoc.Update()

    End Sub
End Class

 

And a model it should work on:

piotrekdoro94_0-1719988945383.png

 

I suspect that there is a problem with the way I'm using sheet metal environment because if I switch to normal part environment it works:

Imports Inventor
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim InventorApp As Inventor.Application

        Try
            InventorApp = Marshal.GetActiveObject("Inventor.Application")
            MessageBox.Show("Connected To Inventor session")

        Catch ex As Exception
            MessageBox.Show("Failed to connect to inventor session")
        End Try

        Dim oPartDoc As PartDocument
        Dim oPartCompDef As SheetMetalComponentDefinition
        
        oPartDoc = InventorApp.ActiveDocument
        oPartCompDef = oPartDoc.ComponentDefinition

        Dim oThickenCollectorFaceCollection As FaceCollection
        Dim oThickenInletFaceCollection1 As FaceCollection
        Dim oThickenInletFaceCollection2 As FaceCollection

        Dim oThickenCollector As ThickenFeature
        Dim oThickenInlet1 As ThickenFeature
        Dim oThickenInlet2 As ThickenFeature

        oThickenCollectorFaceCollection = InventorApp.TransientObjects.CreateFaceCollection() 'Create face collection
        oThickenCollectorFaceCollection.Add(oPartCompDef.Features(1).SurfaceBodies(1).Faces(1)) 'Add collector surface to face collection
        oThickenCollector = oPartCompDef.Features.ThickenFeatures.Add(oThickenCollectorFaceCollection, Convert.ToDouble(CollectorThicknessTextBox.Text) / 10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, PartFeatureOperationEnum.kNewBodyOperation) 'Thicken collector

        oThickenInletFaceCollection1 = InventorApp.TransientObjects.CreateFaceCollection() 'Create face collection
        oThickenInletFaceCollection1.Add(oPartCompDef.Features(2).SurfaceBodies(1).Faces(1)) 'Add inlet 1 surface to face collection
        oThickenInlet1 = oPartCompDef.Features.ThickenFeatures.Add(oThickenInletFaceCollection1, Convert.ToDouble(InletThicknessTextBox.Text) / 10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, PartFeatureOperationEnum.kNewBodyOperation) 'Thicken inlet 1

        oThickenInletFaceCollection2 = InventorApp.TransientObjects.CreateFaceCollection() 'Create face collection
        oThickenInletFaceCollection2.Add(oPartCompDef.Features(3).SurfaceBodies(1).Faces(1)) 'Add inlet 1 surface to face collection
        oThickenInlet2 = oPartCompDef.Features.ThickenFeatures.Add(oThickenInletFaceCollection2, Convert.ToDouble(InletThicknessTextBox.Text) / 10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, PartFeatureOperationEnum.kNewBodyOperation) 'Thicken inlet 2

        oPartDoc.Update()

    End Sub
End Class

 

0 Likes
230 Views
2 Replies
Replies (2)
Message 2 of 3

nstevelmans
Advocate
Advocate

hi, run your solution test.zip works all fine  (inventor 2024), maybe it is the version of inventor

0 Likes
Message 3 of 3

piotrekdoro94
Advocate
Advocate

I've managed to  solve it for now but I have to keep switching document's substyle from general part to sheet metal part and back.

0 Likes