How can I create an iPart/iAssembly with iLogic/VB?

How can I create an iPart/iAssembly with iLogic/VB?

FeelGoodGirl
Advocate Advocate
1,191 Views
6 Replies
Message 1 of 7

How can I create an iPart/iAssembly with iLogic/VB?

FeelGoodGirl
Advocate
Advocate

Hi,

You can create an iPart within Inventor. You can also adjust options here. A previous post concluded that you cannot set those options somewhere. So let's do it differently then.

 

Experience shows that if you ask colleagues to adjust things by hand, they start forgetting this. I now want to create a button that automatically prepares this for them. It doesn't really matter if this is iLogic or in VB. What is the idea of the button:

- Create an iPart/iAssembly
- Customize options:

ymvdbosch_0-1649322685283.png

- Open the iPart/iAssembly screen (just like you normally get when you create an iPart/iAssembly)

 

My problem starts with the first point. I can't figure out how to turn a 'normal' file into an iPart/iAssembly. Hopefully someone can help me with this problem.

 

Thanks in advance!

0 Likes
Accepted solutions (1)
1,192 Views
6 Replies
Replies (6)
Message 2 of 7

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

PartComponentDefinition.CreateFactory method converts a part to an iPartFactory. In the iPartFactory.FactoryOptions you can set the MemberNameType property = kPartNumberMemberNameType and the PartNumberIndexSeparator property = "#".

For a part file:

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim iPartFact As iPartFactory = oCompDef.CreateFactory
iPartFact.FactoryOptions.MemberNameType = kPartNumberMemberNameType
iPartFact.FactoryOptions.PartNumberIndexSeparator = "#"
Thisapplication.CommandManager.ControlDefinitions("AppCreateiPartCmd").Execute

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 7

FeelGoodGirl
Advocate
Advocate

Hi,

 

You are my hero! This is exactly what I'm looking for. I also managed to convert it for an Assembly.

 

I do have one small question. Now when I add a new line I get a #. Only in the line that already exists is a -. Do you have an idea how I can make this a # too?

 

ymvdbosch_2-1649333291359.png

 

 

0 Likes
Message 4 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

I think this is because the first row is created while creating the iPartFactory and the change in options is done afterwards.

Try this added line:

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim iPartFact As iPartFactory = oCompDef.CreateFactory
iPartFact.FactoryOptions.MemberNameType = kPartNumberMemberNameType
iPartFact.FactoryOptions.PartNumberIndexSeparator = "#"
'### added
iPartFact.FactoryOptions.ApplyToAllMembers
'###
Thisapplication.CommandManager.ControlDefinitions("AppCreateiPartCmd").Execute

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 5 of 7

FeelGoodGirl
Advocate
Advocate

Hi,

 

thank you for your quick response. Unfortunately this is not the solution. Now it shows the screen with -. Close the window again and then we get this:

ymvdbosch_0-1649333979568.png

 

0 Likes
Message 6 of 7

Ralf_Krieg
Advisor
Advisor

Hello

 

Seems like first row Member name value is not updated correct.  Can you try this manual overwrtie?

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim iPartFact As iPartFactory = oCompDef.CreateFactory


iPartFact.FactoryOptions.PartNumberType = FactoryOptionsPartNumberTypeEnum.kValuePartNumberType
iPartFact.FactoryOptions.PartNumberValue = ThisDoc.FileName(False) 'without extension

iPartFact.FactoryOptions.IsPartNumberIndexed = True
iPartFact.FactoryOptions.PartNumberIndexSeparator = "#"
iPartFact.FactoryOptions.PartNumberIndexInitialValue = 1
iPartFact.FactoryOptions.PartNumberIndexStepValue=1
iPartFact.FactoryOptions.PartNumberIndexDigits=2

iPartFact.FactoryOptions.MemberNameType = kPartNumberMemberNameType

iPartFact.FactoryOptions.ApplyToAllMembers

Dim oCol As iPartTableColumn = iPartFact.FileNameColumn
oCol.Item(1).Value=ThisDoc.FileName(False) & "#01"

ThisApplication.CommandManager.ControlDefinitions("AppCreateiPartCmd").Execute

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 7 of 7

FeelGoodGirl
Advocate
Advocate

Hi,

Thank you, thank you, thank you!! It now works exactly as i would like. Thank you for your help!

0 Likes