Dear Everybody.
I am learning Inventor programming. A big change is the state.
Would anyone write in a C # programming language that I can switch between states?
I tried to rewrite VB.net but it didn't come together.
Thanks your help.
Dear Everybody.
I am learning Inventor programming. A big change is the state.
Would anyone write in a C # programming language that I can switch between states?
I tried to rewrite VB.net but it didn't come together.
Thanks your help.
I don't know if you can use C programming.
There's a VBA editor and iLogic.
iLogic is BASED on VB.net but not exactly the same.
An in depth description of what you are trying to achieve would be very useful too.
Post your VB.net code and someone will have a look at why it won't work in iLogic.
I don't know if you can use C programming.
There's a VBA editor and iLogic.
iLogic is BASED on VB.net but not exactly the same.
An in depth description of what you are trying to achieve would be very useful too.
Post your VB.net code and someone will have a look at why it won't work in iLogic.
I'll be a little more specific.
I would like to select one of the ipt states from a combo box.
Insert the selected state into the assembly.
I practice programming in visual studio 2019, but I can't find anything about the states that would be in C #.
I would like to ask for an example of a C # language for state control
Inventor 2022 api help example that's not what I want VB.NET:
Public Sub CreateModelState()
' Set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry
' Create a matrix. A new matrix is initialized with an identity matrix.
Dim oMatrix As Matrix Set oMatrix = oTG.CreateMatrix
' Add the first occurrence.
Dim oOcc1 As ComponentOccurrence
Set oOcc1 = oAsmCompDef.Occurrences.Add("C:\Temp\Part1.ipt", oMatrix)
' Set the translation portion of the matrix so the ' second part will be positioned at (3,2,1).
Call oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1))
' Add the second occurrence.
Dim oOcc2 As ComponentOccurrence
Set oOcc2 = oAsmCompDef.Occurrences.Add("C:\Temp\Part2.ipt", oMatrix)
' Create a new level of detail representation.
' The new representation is automatically activated.
Dim oModelState As ModelState
Set oModelState = oAsmCompDef.ModelStates.Add("Part2Suppressed")
' Suppress the second component in the new model state.
' If the document "C:\Temp\Part2.ipt" is not currently referenced
' elsewhere, it will be closed.
oOcc2.SuppressEnd Sub
I'll be a little more specific.
I would like to select one of the ipt states from a combo box.
Insert the selected state into the assembly.
I practice programming in visual studio 2019, but I can't find anything about the states that would be in C #.
I would like to ask for an example of a C # language for state control
Inventor 2022 api help example that's not what I want VB.NET:
Public Sub CreateModelState()
' Set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry
' Create a matrix. A new matrix is initialized with an identity matrix.
Dim oMatrix As Matrix Set oMatrix = oTG.CreateMatrix
' Add the first occurrence.
Dim oOcc1 As ComponentOccurrence
Set oOcc1 = oAsmCompDef.Occurrences.Add("C:\Temp\Part1.ipt", oMatrix)
' Set the translation portion of the matrix so the ' second part will be positioned at (3,2,1).
Call oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1))
' Add the second occurrence.
Dim oOcc2 As ComponentOccurrence
Set oOcc2 = oAsmCompDef.Occurrences.Add("C:\Temp\Part2.ipt", oMatrix)
' Create a new level of detail representation.
' The new representation is automatically activated.
Dim oModelState As ModelState
Set oModelState = oAsmCompDef.ModelStates.Add("Part2Suppressed")
' Suppress the second component in the new model state.
' If the document "C:\Temp\Part2.ipt" is not currently referenced
' elsewhere, it will be closed.
oOcc2.SuppressEnd Sub
I don't know if it is what you are looking for, but here is rewritten example to C#. I keep original code as comments.
The API object model is the same for VBA, VB.NET (iLogic) and C#. Differences are only in language syntax.
public void CreateModelState()
{
//Public Sub CreateModelState()
// ' Set a reference to the assembly component definintion.
// ' This assumes an assembly document is open.
// Dim oAsmCompDef As AssemblyComponentDefinition
// Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
var oAsmDoc = ThisApplication.ActiveDocument as AssemblyDocument;
var oAsmCompDef = oAsmDoc.ComponentDefinition;
// ' Set a reference to the transient geometry object.
// Dim oTG As TransientGeometry
// Set oTG = ThisApplication.TransientGeometry
var oTG = ThisApplication.TransientGeometry;
// ' Create a matrix. A new matrix is initialized with an identity matrix.
// Dim oMatrix As Matrix
// Set oMatrix = oTG.CreateMatrix
var oMatrix = oTG.CreateMatrix();
// ' Add the first occurrence.
// Dim oOcc1 As ComponentOccurrence
// Set oOcc1 = oAsmCompDef.Occurrences.Add("C:\Temp\Part1.ipt", oMatrix)
var oOcc1 = oAsmCompDef.Occurrences.Add(@"C:\Temp\Part1.ipt", oMatrix);
// ' Set the translation portion of the matrix so the
// ' second part will be positioned at (3,2,1).
// Call oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1))
oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1));
// ' Add the second occurrence.
// Dim oOcc2 As ComponentOccurrence
// Set oOcc2 = oAsmCompDef.Occurrences.Add("C:\Temp\Part2.ipt", oMatrix)
var oOcc2 = oAsmCompDef.Occurrences.Add(@"C:\Temp\Part2.ipt", oMatrix);
// ' Create a new level of detail representation.
// ' The new representation is automatically activated.
// Dim oModelState As ModelState
// Set oModelState = oAsmCompDef.ModelStates.Add("Part2Suppressed")
var oModelState = oAsmCompDef.ModelStates.Add("Part2Suppressed");
// ' Suppress the second component in the new model state.
// ' If the document "C:\Temp\Part2.ipt" is not currently referenced
// ' elsewhere, it will be closed.
oOcc2.Suppress();
//End Sub
}
I don't know if it is what you are looking for, but here is rewritten example to C#. I keep original code as comments.
The API object model is the same for VBA, VB.NET (iLogic) and C#. Differences are only in language syntax.
public void CreateModelState()
{
//Public Sub CreateModelState()
// ' Set a reference to the assembly component definintion.
// ' This assumes an assembly document is open.
// Dim oAsmCompDef As AssemblyComponentDefinition
// Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
var oAsmDoc = ThisApplication.ActiveDocument as AssemblyDocument;
var oAsmCompDef = oAsmDoc.ComponentDefinition;
// ' Set a reference to the transient geometry object.
// Dim oTG As TransientGeometry
// Set oTG = ThisApplication.TransientGeometry
var oTG = ThisApplication.TransientGeometry;
// ' Create a matrix. A new matrix is initialized with an identity matrix.
// Dim oMatrix As Matrix
// Set oMatrix = oTG.CreateMatrix
var oMatrix = oTG.CreateMatrix();
// ' Add the first occurrence.
// Dim oOcc1 As ComponentOccurrence
// Set oOcc1 = oAsmCompDef.Occurrences.Add("C:\Temp\Part1.ipt", oMatrix)
var oOcc1 = oAsmCompDef.Occurrences.Add(@"C:\Temp\Part1.ipt", oMatrix);
// ' Set the translation portion of the matrix so the
// ' second part will be positioned at (3,2,1).
// Call oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1))
oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1));
// ' Add the second occurrence.
// Dim oOcc2 As ComponentOccurrence
// Set oOcc2 = oAsmCompDef.Occurrences.Add("C:\Temp\Part2.ipt", oMatrix)
var oOcc2 = oAsmCompDef.Occurrences.Add(@"C:\Temp\Part2.ipt", oMatrix);
// ' Create a new level of detail representation.
// ' The new representation is automatically activated.
// Dim oModelState As ModelState
// Set oModelState = oAsmCompDef.ModelStates.Add("Part2Suppressed")
var oModelState = oAsmCompDef.ModelStates.Add("Part2Suppressed");
// ' Suppress the second component in the new model state.
// ' If the document "C:\Temp\Part2.ipt" is not currently referenced
// ' elsewhere, it will be closed.
oOcc2.Suppress();
//End Sub
}
Thank's your help michael.navara.
I am learning how to program Inventor and I'm looking at Inventor / Help / Api.I cannot find many programming examples of this new state.
First, I want to learn how to create a state in ipt. For example, I want to create a cylinder and a cube. Then create separate states for them.
And I want to put the cube or the cylinder in the assembly.
I don't know how I could get started.
I would ask for help in this. With an example or a website link ..
Thank's your help michael.navara.
I am learning how to program Inventor and I'm looking at Inventor / Help / Api.I cannot find many programming examples of this new state.
First, I want to learn how to create a state in ipt. For example, I want to create a cylinder and a cube. Then create separate states for them.
And I want to put the cube or the cylinder in the assembly.
I don't know how I could get started.
I would ask for help in this. With an example or a website link ..
not sure if this helps you a lot but maybe you find this blogpost useful
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.
Blog: hjalte.nl - github.com
not sure if this helps you a lot but maybe you find this blogpost useful
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.
Blog: hjalte.nl - github.com
Can't find what you're looking for? Ask the community or share your knowledge.