Generate iPart Files using iLogic/VBA

Generate iPart Files using iLogic/VBA

Anonymous
Not applicable
4,344 Views
5 Replies
Message 1 of 6

Generate iPart Files using iLogic/VBA

Anonymous
Not applicable

Here's the proccess we want to accomplish:

 

iLogic rule to Modify iPart factory table - DONE

If anyone is interested, Here's the code used to change values in the iPart table.

 

' Rule to Change iPart table from iPart File
Dim oDoc As PartDocument = ThisDoc.Document 
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition 
Dim initRowIndex As Integer
Dim oFactory As iPartFactory = oDef.iPartFactory

' Edit rows 1 and 2, assign values to column 3 in table
oFactory.TableRows.Item(1).Item(3).Value = 1119
oFactory.TableRows.Item(2).Item(3).Value = 2229

iLogic rule to reGenerate files to reflect changes - HOW?

currently we use this method, but we would to automate this using iLogic

genfiles.png

So it will update the referenced file when an update has been made to the specific table row.

 

I have heard that iLogic and iParts don't mix, however it seems to be the easiest solution to progate changes from a master design to several unique versions.

 

Any advice is greatly appreciated.

 

Cheers,

Ben

0 Likes
Accepted solutions (1)
4,345 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

Found a way to update the ipart using iLogic then force the member files to regenerate, see the code below:

 

Dim oDoc As PartDocument = ThisDoc.Document 
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition 
Dim initRowIndex As Integer
Dim oFactory As iPartFactory = oDef.iPartFactory

' Edit row 1 & 2 of table
oFactory.TableRows.Item(1).Item(3).Value = 2322
oFactory.TableRows.Item(2).Item(3).Value = 4444

' Iterate All Rows of iPart
Dim oRow As iPartTableRow
For Each oRow In oFactory.TableRows
	' Generate the member and file, (overwrites member file or creates new file)
	oFactory.CreateMember(oRow)
Next

iLogicVb.UpdateWhenDone = True

This is immensely useful for our purposes, hope it helps you too.

Message 3 of 6

meck
Collaborator
Collaborator

Hi Ben,

I tried using this code, and it does generate files, but when I try to make a drawing from the iPart factory I get an error saying "Unable to create a view of member MYPARTNUMBER because of error generating source file."

 

Strangely MYPARTNUMBER has a bizarre symbol replacing the first letter.

 

Any ideas?

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hi Meck,

I'm not sure what that error is referring to.

But I can help you fix it. Please provide a zip file containing; a
simplified version of the problem you have:

- An iPart
- Some generated parts from the iPart
- And a drawing.

If these files create the error you describe then I can try to see how to
fix it.

Cheers,
Ben
Message 5 of 6

meck
Collaborator
Collaborator

Thanks for replying Ben,

Turns out the drafters say they want this functionality to be manual. Which if it wasn't going to be very difficult to strip proprietary information from the model I would still like an answer. But since they do not need this anymore I'm cannot justify spending the extra time to make this able to be displayed here.

 

Thanks again for taking the time to answer!

 

Mike

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 6 of 6

Anonymous
Not applicable
No worries mate! 👍
0 Likes