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: 

creat iassembly factory all member

4 REPLIES 4
Reply
Message 1 of 5
Kgokhankaya
470 Views, 4 Replies

creat iassembly factory all member

hi

i want to creat iassembly member with macro

i write below code but give error "type mismatch"
how can i creat iassembly members with macro



Private Sub RegenerateExisting()

On Error Resume Next



' Open the factory document

Dim oFacDoc As AssemblyDocument

Set oFacDoc = oInventorApp.Documents.Open(sFacFullFileName)



Dim oCompDef As AssemblyComponentDefinition

Set oCompDef = oFacDoc.ComponentDefinition



Dim iNumRows As Integer

Dim oiPrtFac As iAssemblyFactory

Set oiPrtFac = oCompDef.iAssemblyFactory



iNumRows = oiPrtFac.TableRows.Count



Dim iRow As Integer

Dim oRow As iAssemblyTableRow

For iRow = 1 To iNumRows

' Need to retrieve the factory each time since the

' table objects are only valid for one transaction

Set oiPrtFac = oCompDef.iAssemblyFactory



Set oRow = oiPrtFac.TableRows(iRow)



' Get the filename for the row

Dim sMemFileName As String

sMemFileName = oRow.PartName



' Check if this file exists in the member file folder

If DoesFileExist(sMemFolderLoc + sMemFileName) = True Then

' Regenerate the member

Dim oMem As iAssemblyMember

Set oMem = oiPrtFac.CreateMember(iRow) {color:#ff0000}' This is row to give error{color}



Dim oMemDoc As Document

Set oMemDoc = oMem.Parent.Document



' Update the member

oMemDoc.Update

oMemDoc.Save

oMemDoc.Close

End If

Next



oFacDoc.Close



End Sub
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Kgokhankaya


The latest version of the
iAssemblyFactory.CreateMember does not return the member object. So change
this:

 

Set oMem = oiPrtFac.CreateMember(iRow)

 

to

 

Call oiPrtFac.CreateMember(iRow)

 

To get the member document, you'll need to store
the full file name and explicitly open that document using Documents.Open
method.

 

Sanjay-
Message 3 of 5
MattH_Work
in reply to: Kgokhankaya

> {quote:title=Guest wrote:}{quote}
>

>

>
 

>
To get the member document, you'll need to store
> the full file name and explicitly open that document using Documents.Open
> method.

>
 

>
Sanjay-

>

Struggling with the same thing at the moment, so the follow on equestion is as follows...

How do we get the full file name of the iAssembly member being generated from the current factory row?

Regards

MattH

MattH
Product Design Collection 2025
Vault Pro 2025
Message 4 of 5
Anonymous
in reply to: Kgokhankaya


The directory that the member will be located in is
returned by iAssemblyFactory.MemberCacheDir and the filename is returned by
iAssemblyTableRow.DocumentName.

 

Sanjay-
Message 5 of 5
Anonymous
in reply to: Anonymous

files not Regenerated if exists in subdir  any ideas?Smiley Sad

 

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

Post to forums  

Autodesk Design & Make Report