Autodesk Inventor Customization
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
creat iassembly factory all member
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
187 Views, 4 Replies
02-21-2010 03:27 PM
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
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
*Sanjay Ramaswamy \(Autodesk\)
Re: creat iassembly factory all member
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-24-2010 04:03 PM in reply to:
altargokhan
The latest version of the
iAssemblyFactory.CreateMember does not return the member object. So change
this:
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.
the full file name and explicitly open that document using Documents.Open
method.
Sanjay-
Re: creat iassembly factory all member
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-25-2010 08:41 AM in reply to:
altargokhan
> {quote:title=Guest wrote:}{quote}
>
>
>
>
>
>
>
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
>
>
>
>
To get the member document, you'll need to store
> the full file name and explicitly open that document using Documents.Open
> method.
> 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
*Sanjay Ramaswamy \(Autodesk\)
Re: creat iassembly factory all member
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-25-2010 03:15 PM in reply to:
altargokhan
The directory that the member will be located in is
returned by iAssemblyFactory.MemberCacheDir and the filename is returned by
iAssemblyTableRow.DocumentName.
returned by iAssemblyFactory.MemberCacheDir and the filename is returned by
iAssemblyTableRow.DocumentName.
Sanjay-
Re: creat iassembly factory all member
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-19-2012 03:42 AM in reply to:
*Sanjay Ramaswamy \(Autodesk\)
files not Regenerated if exists in subdir any ideas?![]()

