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: 

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

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
FeelGoodGirl
328 Views, 6 Replies

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

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!

6 REPLIES 6
Message 2 of 7
Ralf_Krieg
in reply to: FeelGoodGirl

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 GmbH
www.rkw-solutions.com
Message 3 of 7
FeelGoodGirl
in reply to: FeelGoodGirl

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

 

 

Message 4 of 7
Ralf_Krieg
in reply to: FeelGoodGirl

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 GmbH
www.rkw-solutions.com
Message 5 of 7
FeelGoodGirl
in reply to: FeelGoodGirl

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

 

Message 6 of 7
Ralf_Krieg
in reply to: FeelGoodGirl

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 GmbH
www.rkw-solutions.com
Message 7 of 7
FeelGoodGirl
in reply to: FeelGoodGirl

Hi,

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

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report