• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor Customization

    Reply
    Valued Contributor
    Posts: 82
    Registered: ‎11-09-2007

    creat iassembly factory all member

    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
    Please use plain text.
    *Sanjay Ramaswamy \(Autodesk\)

    Re: creat iassembly factory all member

    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:

     

    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-
    Please use plain text.
    Valued Contributor
    Posts: 117
    Registered: ‎11-16-2007

    Re: creat iassembly factory all member

    02-25-2010 08:41 AM in reply to: altargokhan
    > {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
    Please use plain text.
    *Sanjay Ramaswamy \(Autodesk\)

    Re: creat iassembly factory all member

    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.

     

    Sanjay-
    Please use plain text.
    Contributor
    maxstel
    Posts: 21
    Registered: ‎09-21-2011

    Re: creat iassembly factory all member

    02-19-2012 03:42 AM in reply to: *Sanjay Ramaswamy \(Autodesk\)

    files not Regenerated if exists in subdir  any ideas?:smileysad:

     

    Please use plain text.