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: 

problem using AddCustomi​PartMember

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mitcham_boy
598 Views, 3 Replies

problem using AddCustomi​PartMember

Hi

 

I find that the method, AddCustomiPartMember , works fine if i pass the "Row" parameter as a number but i can't get it to work when i pass it as a string .  This is what the help file states:

 

Sub AddCustomiPartMember(FactoryFileName As String, Position As Matrix, FullFileName As String, ByRef Row As [optional] VARIANT, ByRef CustomInput As [optional] VARIANT, Result As [out, retval] ComponentOccurrence*)
 
 
Parameters 
Description 
..
.. 
..
.. 
..
.. 
Row 
Optional input Variant that specifies the row for the member within the factory. The row index is specified either by a Long (row index), a String (part identifier, i.e. ''[Height=1.000 in][Length=2.000 in][Radius=0.250 in]''), or an iPartTableRow object.
 
..
... 

 

Here's the code that doesn't work :

 

Sub test3()
    Dim myAssembly As AssemblyDocument, my_part As ComponentOccurrence, my_pos As Matrix
    Dim ifactory_path As String, ipart_path As String, iselect As String
    Set myAssembly = ThisApplication.ActiveDocument
    Set my_pos = ThisApplication.TransientGeometry.CreateMatrix
    Dim custom_vars(1 To 2) As String
    iselect = "[my_var=18mm]"
    custom_vars(1) = "13mm"
    custom_vars(2) = "25mm"    
    ifactory_path = "D:\my_ifactory.ipt"
    ipart_path ="D:\selected_ipart.ipt"    
    Set my_part = myAssembly.ComponentDefinition.Occurrences.AddCustomiPartMember(ifactory_path, my_pos, ipart_path, iselect, custom_vars)
End Sub

 

but if i swap out iselect for a number such as "2" etc then it works fine !!

 

Can anyone help me out??

Many thanks in advance.

Dan

3 REPLIES 3
Message 2 of 4

Hi,

 

It is a known issue  AddCustomiPartMember does not work with TableRow. Here is some snippet with which we logged this issue.  

 

... ....

 

Dim oTblRowCust As iPartTableRow
Set oTblRowCust = oPartDef.iPartFactory.TableRows.Item(2)

 

.... ...

 

' by number, can work

Call oMatrix.SetTranslation(oTG.CreateVector(300, 0, 0))
Set oOcc = oAsmCompDef.Occurrences.AddCustomiPartMember(customiPartFile, oMatrix, "C:\temp\gear1.ipt", 1)

' 1st Row

 

'By iPart Table Row, cannot work!

Call oMatrix.SetTranslation(oTG.CreateVector(400, 0, 0))
Set oOcc = oAsmCompDef.Occurrences.AddCustomiPartMember(customiPartFile, oMatrix, "C:\temp\gear2.ipt", oTblRowCust) ' 2nd Row

 

' By string identifier, cannot work

Call oMatrix.SetTranslation(oTG.CreateVector(500, 0, 0))
Set oOcc = oAsmCompDef.Occurrences.AddCustomiPartMember(customiPartFile, oMatrix, "C:\temp\gear3.ipt", "CustomFactory [d0=2.3][d1=6.937][d2=2.552]")

 

So, you may have to modify the factory iPart beforehand. Then Insert the ipart by using AddCustomiPartMember method.Sorry for the problem.

Message 3 of 4
c.silby
in reply to: xiaodong_liang

Is this still the case with Inventor 2014?

Message 4 of 4

Hello.

 

I'm trying to insert custom iPart using AddCustomiPartMember in Inventor 2019. I want to define row by specifying a string (e.g. "CustomFactory [d0=2.3][d1=6.937][d2=2.552]") and it does not work.

 

Example I'm trying is from DevBlog. I get the error (Unspecified error) in every line where row is defined by string. Inserting by providing row index works fine.

 

Should this work in 2019?

 

Thanks,

 

Sašo

-----------------------------------------------------------------------
AutoDXF - automatic flat pattern creation and batch export to DXF for Inventor

Please use "Accept as Solution" & give "Kudos" if this response helped you.

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

Post to forums  

Autodesk Design & Make Report