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:
- 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!
Solved! Go to Solution.
Solved by Ralf_Krieg. Go to 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
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?
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
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:
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
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.