Assembly Generator to create new part files from part template files

Assembly Generator to create new part files from part template files

kwilson_design
Collaborator Collaborator
156 Views
1 Reply
Message 1 of 2

Assembly Generator to create new part files from part template files

kwilson_design
Collaborator
Collaborator

Hey everyone. I'm working on creating an Assembly Generator that will use part template files to create new part files. Right now my code is using the template files only but I need new files instead of editing the template files. How would I go about doing this? I've read on some topics regarding kparts but I don't know how to implement that into the code. I also don't want the browser names to be "left_channel:1", "right_channel:1" etc but rather be the new part files instead.

 

Dim ChannelTemplateFolder As String = "C:\_VaultWorkspace\Designs\ETO\Templates\Generators\AVR\"
Dim SpacerKitFolder As String = "C:\_VaultWorkspace\Designs\ETO\U numbers\U124\"
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition


'Place Left channel part
Dim LeftChannel = Components.Add("Left_Channel:1", ChannelTemplateFolder &  "AVR Base Generator (Left Double Channel Design).ipt", position := Nothing, grounded := True, visible := True, appearance := Nothing)

'Place Spacer Kit1
Dim SpacerKit1 = Components.Add("Spacer_Kit:1", SpacerKitFolder & "U124-00001-01.iam", position := Nothing, grounded := False, visible := True, appearance := Nothing)

'Place Right channel part
Dim RightChannel = Components.Add("Right_Channel:1", ChannelTemplateFolder & "AVR Base Generator (Right Double Channel Design).ipt", position := Nothing, grounded := False, visible := True, appearance := Nothing)

'Constrain Spacer kit1
Constraints.AddByiMates("Spacer1FaceToLeftChannelFace", "Spacer_Kit:1", "iMate:left_face", "Left_Channel:1", "iMate:left_face")
Constraints.AddByiMates("Spacer1FaceToRightChannelFace", "Spacer_Kit:1", "iMate:right_face", "Right_Channel:1", "iMate:right_face")
Constraints.AddByiMates("Spacer1FaceToLeftChannelSpacerMounting1", "Spacer_Kit:1", "iMate:spacer_mounting", "Left_Channel:1", "iMate:spacer_mounting1")
Constraints.AddByiMates("Spacer1FaceToRightChannelSpacerMounting1", "Spacer_Kit:1", "iMate:spacer_mounting", "Right_Channel:1", "iMate:spacer_mounting1")

I've also I started to create a "link parameters" rule in the Assembly Generator template so that the user parameters of the assembly can drive the model parameters of the part files, but again I'm using the "left_channel:1" etc browser names to communicate but what I really need to use is whatever code the new part names would be instead. Basically I need to get away from editing the template files directly and edit new parts made based off the template files instead. Hope that makes sense lol. Any help would be greatly appreciated 🙂

 

Parameter("Left_Channel:1", "Holes_Distance_To_Insulator1_C_C") = Holes_Distance_To_Insulator1_C_C
Parameter("Right_Channel:1", "Holes_Distance_To_Insulator1_C_C") = Holes_Distance_To_Insulator1_C_C
Parameter("Left_Channel:1", "Base_Length") = Base_Length
Parameter("Right_Channel:1", "Base_Length") = Base_Length
Parameter("Left_Channel:1", "Insulator1_To_Insulator2__C_C") = Insulator1_To_Insulator2__C_C
Parameter("Right_Channel:1", "Insulator1_To_Insulator2__C_C") = Insulator1_To_Insulator2__C_C
Parameter("Left_Channel:1", "Edge_Of_Channel_To_Center_Of_Bearing_Hole") = Edge_Of_Channel_To_Center_Of_Bearing_Hole
Parameter("Right_Channel:1", "Edge_Of_Channel_To_Center_Of_Bearing_Hole") = Edge_Of_Channel_To_Center_Of_Bearing_Hole

 

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
0 Likes
157 Views
1 Reply
Reply (1)
Message 2 of 2

kwilson_design
Collaborator
Collaborator

It's almost like I need to run something like the code below, but more automated since I already know the folder the new part files need to be saved at, in this case our C:\_VaultWorkspace\Designs\ETO\Components\PS501\ folder.

 

ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, "MyPart.ipt")
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyCreateComponentCmd").Execute()

The issue becomes if I run something like that upfront, it's already wanting them to place the component in 3D space when I would prefer to script in the placement. Not to mention and they create a new filename for their new parts, how do I handle the rest of the code where i want to tie in the constraints if the filename will always change? Maybe that is not the best approach to go that route.

 

What I'm trying to envision creating is create an assembly template that will create new part components from existing template part components. The new part components will be saved in the same folder. The new part components origin YZ and XZ planes will also get constrained to the new assembly's origin YZ and XZ planes. From there, the spacer kit iMates will get constrained to the respective iMates on the new part components. I then have another tab on my iLogic Form for the user to be able to edit the model parameters of the new component files directly from the new assembly. This part is working great,  but again, it's directly editing the template files and I need it to edit the newly created part components instead.

 

Regards,
Kenny
If this post solved your issue please mark "Accept as Solution". It helps everyone...really!
0 Likes