Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SheetMetal in assembly API VB.NET

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
florian_wenzel
273 Views, 2 Replies

SheetMetal in assembly API VB.NET

florian_wenzel
Advocate
Advocate

Hi,

 

Inventor 2022

API. VB.NET Visual Studio

 

 

I try to Change SubType of a Part (From Part to  SheetMetal) in Assembly Enviroment.

 

My Goal i to Create a CounterFlange

The Problem is to change the SubType Docuemnt.

 

I Think, the Problem is, that iam i SubAssembly, ActiveDocument is Probably the Main Assembly.

How i can make the PartDocuemnt Active in Assembly?

Is this the Problem ?

 

This is My Code:

 

 

        Dim oArc As SketchArc
        oArc = oSketchPart_A.SketchArcs.AddByCenterStartEndPoint(oPointCenterArc, oSketchLine_06.EndSketchPoint, oSketchLine_07.EndSketchPoint)



        Dim oPathline As Path = oPart_A_Def.Features.CreatePath(oArc)

        oOccAssembly_Middle.Edit()
        'oOccPartA.Edit()
        Dim oRefComponents As ReferenceComponents = oPart_A_Def.ReferenceComponents

        g_inventorApplication.ActiveDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
        oPartA.Update()

        Dim oSheetCompDef As SheetMetalComponentDefinition = oPartA.ComponentDefinition
        Dim oSheetMetallFeatures As SheetMetalFeatures = oSheetCompDef.Features

        Dim oStyle As SheetMetalStyle
        oStyle = oSheetCompDef.SheetMetalStyles.Item(1)


        oStyle.Thickness = "2"
        oStyle.BendRadius = "Stärke"
        oStyle.BendReliefDepth = "Stärke * 0.5"
        oStyle.BendReliefShape = BendReliefShapeEnum.kRoundBendReliefShape
        oStyle.BendReliefWidth = "Stärke"
        oStyle.BendTransition = BendTransitionEnum.kArcBendTransition
        oStyle.BendTransitionArcRadius = "Stärke * 2.0"
        oStyle.CornerReliefShape = CornerReliefShapeEnum.kRoundCornerReliefShape
        oStyle.CornerReliefSize = "Stärke * 4.0"
        oStyle.MinimumRemnant = "Stärke * 2.0"
        oPartA.Update()





        Dim oContourFlanges As ContourFlangeFeatures = oSheetCompDef.Features.ContourFlangeFeatures
        Dim oContourFlangeDef As ContourFlangeDefinition
        oContourFlangeDef = oContourFlanges.CreateContourFlangeDefinition(oPathline)
        Call oContourFlangeDef.SetDistanceExtent(13, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)

        Dim oContourFlange As ContourFlangeFeature = oContourFlanges.Add(oContourFlangeDef)

 

 

 

 

I got Error:

Wrong Parameter

florian_wenzel_1-1655909152213.png

 

florian_wenzel_0-1655909122861.png

 

 

 

0 Likes

SheetMetal in assembly API VB.NET

Hi,

 

Inventor 2022

API. VB.NET Visual Studio

 

 

I try to Change SubType of a Part (From Part to  SheetMetal) in Assembly Enviroment.

 

My Goal i to Create a CounterFlange

The Problem is to change the SubType Docuemnt.

 

I Think, the Problem is, that iam i SubAssembly, ActiveDocument is Probably the Main Assembly.

How i can make the PartDocuemnt Active in Assembly?

Is this the Problem ?

 

This is My Code:

 

 

        Dim oArc As SketchArc
        oArc = oSketchPart_A.SketchArcs.AddByCenterStartEndPoint(oPointCenterArc, oSketchLine_06.EndSketchPoint, oSketchLine_07.EndSketchPoint)



        Dim oPathline As Path = oPart_A_Def.Features.CreatePath(oArc)

        oOccAssembly_Middle.Edit()
        'oOccPartA.Edit()
        Dim oRefComponents As ReferenceComponents = oPart_A_Def.ReferenceComponents

        g_inventorApplication.ActiveDocument.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
        oPartA.Update()

        Dim oSheetCompDef As SheetMetalComponentDefinition = oPartA.ComponentDefinition
        Dim oSheetMetallFeatures As SheetMetalFeatures = oSheetCompDef.Features

        Dim oStyle As SheetMetalStyle
        oStyle = oSheetCompDef.SheetMetalStyles.Item(1)


        oStyle.Thickness = "2"
        oStyle.BendRadius = "Stärke"
        oStyle.BendReliefDepth = "Stärke * 0.5"
        oStyle.BendReliefShape = BendReliefShapeEnum.kRoundBendReliefShape
        oStyle.BendReliefWidth = "Stärke"
        oStyle.BendTransition = BendTransitionEnum.kArcBendTransition
        oStyle.BendTransitionArcRadius = "Stärke * 2.0"
        oStyle.CornerReliefShape = CornerReliefShapeEnum.kRoundCornerReliefShape
        oStyle.CornerReliefSize = "Stärke * 4.0"
        oStyle.MinimumRemnant = "Stärke * 2.0"
        oPartA.Update()





        Dim oContourFlanges As ContourFlangeFeatures = oSheetCompDef.Features.ContourFlangeFeatures
        Dim oContourFlangeDef As ContourFlangeDefinition
        oContourFlangeDef = oContourFlanges.CreateContourFlangeDefinition(oPathline)
        Call oContourFlangeDef.SetDistanceExtent(13, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)

        Dim oContourFlange As ContourFlangeFeature = oContourFlanges.Add(oContourFlangeDef)

 

 

 

 

I got Error:

Wrong Parameter

florian_wenzel_1-1655909152213.png

 

florian_wenzel_0-1655909122861.png

 

 

 

2 REPLIES 2
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

This is how you can change a part of an assembly.

Dim doc As AssemblyDocument = ThisDoc.Document

' Get the part occurrence object
Dim oOccPartA = doc.ComponentDefinition.Occurrences.
    Cast(Of ComponentOccurrence).
    Where(Function(o) o._DisplayName = "PartA").
    FirstOrDefault()

' Get the document that is refrenced by the occurrence
Dim partDoc As PartDocument = oOccPartA.ReferencedDocumentDescriptor.ReferencedDocument

' Change the sub type
partDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

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

This is how you can change a part of an assembly.

Dim doc As AssemblyDocument = ThisDoc.Document

' Get the part occurrence object
Dim oOccPartA = doc.ComponentDefinition.Occurrences.
    Cast(Of ComponentOccurrence).
    Where(Function(o) o._DisplayName = "PartA").
    FirstOrDefault()

' Get the document that is refrenced by the occurrence
Dim partDoc As PartDocument = oOccPartA.ReferencedDocumentDescriptor.ReferencedDocument

' Change the sub type
partDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

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

Message 3 of 3

florian_wenzel
Advocate
Advocate

Hi @JelteDeJong ,

 

Thanks for Help

Thanks for Solution.

 

oPartA.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

🙂

 

 

0 Likes

Hi @JelteDeJong ,

 

Thanks for Help

Thanks for Solution.

 

oPartA.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"

🙂

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report