Wednesday, February 27, 2019

change Referance file name VBA

change Referance file name VBA

hi
i want to change name of files referanced iam file
i write code but give me error (Wrong number of arguments or invaild property assignment)
how do you change referance files name
thanks

Private Sub Form_Load()
Dim invApprentice As New ApprenticeServerComponent
Dim odoc As ApprenticeServerDocument
Set odoc = invApprentice.Open("C:\Altar\Assembly1.iam")


Dim oRefDoc As ApprenticeServerDocument
For Each oRefDoc In odoc.AllReferencedDocuments
oRefDoc.FullFileName = InputBox("Change File Name", "Change")

Next
Set odoc = Nothing
DoEvents

End Sub
Report


Re: change Referance file name VBA

Hi -

You can't change file names that way.

It sounds like you should be looking at ApprenticeServer's FileSaveAs object. Check out the API documentation for this.

There's also some information in the Apprentice Server overview section on this.

Cheers,
Jeff
Report

Re: change Referance file name VBA

hi jeff
thank you very much for answer

are there more Tutorials inventor Apprentice

Merry chrismas
Report



Re: change Referance file name VBA

Jeff, the example code from Autodesk does not work. Even the example from
ADN website does not work.

Joe ...


wrote in message 
news:6310790@discussion.autodesk.com...
Hi -

You can't change file names that way.

It sounds like you should be looking at ApprenticeServer's FileSaveAs 
object. Check out the API documentation for this.

There's also some information in the Apprentice Server overview section on 
this.

Cheers,
Jeff

Report

Re: change Referance file name VBA

hi joe
this code is apprentice code, also Apprentice cannot be used within
Inventor’s VBA, so this sample must be run from either Visual Basic or VBA within another product, i.e.

Dim oApprentice As New ApprenticeServerComponent
' Open a document.
Dim oDoc As ApprenticeServerDocument
Set oDoc = oApprentice.Open("C:\Temp\Assembly1.iam")
' Iterate through the references looking for a
' reference to a specific file.
Dim oRefFileDesc As ReferencedFileDescriptor
For Each oRefFileDesc In oDoc.ReferencedFileDescriptors
If oRefFileDesc.FullFileName = "C:\Temp\OldPart.ipt" Then
' Replace the reference.
Call oRefFileDesc.PutLogicalFileNameUsingFull( _ "C:\Temp\NewPart.ipt")
Exit For
End If Next
' Set a reference to the FileSaveAs object.
Dim oFileSaveAs As FileSaveAs
Set oFileSaveAs = oApprentice.FileSaveAs
' Save the assembly.
Call oFileSaveAs.AddFileToSave(oDoc, oDoc.FullFileName)
Call oFileSaveAs.ExecuteSave
Report

in reply to: Rank

Re: change Referance file name VBA

hi joe
this code is apprentice code, also Apprentice cannot be used within
Inventor’s VBA, so this sample must be run from either Visual Basic or VBA within another product, i.e.

Dim oApprentice As New ApprenticeServerComponent
' Open a document.
Dim oDoc As ApprenticeServerDocument
Set oDoc = oApprentice.Open("C:\Temp\Assembly1.iam")
' Iterate through the references looking for a
' reference to a specific file.
Dim oRefFileDesc As ReferencedFileDescriptor
For Each oRefFileDesc In oDoc.ReferencedFileDescriptors
If oRefFileDesc.FullFileName = "C:\Temp\OldPart.ipt" Then
' Replace the reference.
Call oRefFileDesc.PutLogicalFileNameUsingFull( _ "C:\Temp\NewPart.ipt")
Exit For
End If Next
' Set a reference to the FileSaveAs object.
Dim oFileSaveAs As FileSaveAs
Set oFileSaveAs = oApprentice.FileSaveAs
' Save the assembly.
Call oFileSaveAs.AddFileToSave(oDoc, oDoc.FullFileName)
Call oFileSaveAs.ExecuteSave


Re: change Referance file name VBA

Sorry - this code does not work. It fails on the
"PutLogicalFilenameUsingFull" method.

I am running it in VB6SP6 with IV2010 loaded.

Joe ...


wrote in message news:6314748@discussion.autodesk.com...
hi joe
this code is apprentice code, also Apprentice cannot be used within
Inventor's VBA, so this sample must be run from either Visual Basic or VBA 
within another product, i.e.

Dim oApprentice As New ApprenticeServerComponent
' Open a document.
Dim oDoc As ApprenticeServerDocument
Set oDoc = oApprentice.Open("C:\Temp\Assembly1.iam")
' Iterate through the references looking for a
' reference to a specific file.
Dim oRefFileDesc As ReferencedFileDescriptor
For Each oRefFileDesc In oDoc.ReferencedFileDescriptors
If oRefFileDesc.FullFileName = "C:\Temp\OldPart.ipt" Then
' Replace the reference.
Call oRefFileDesc.PutLogicalFileNameUsingFull( _ 
"C:\Temp\NewPart.ipt")
Exit For
End If Next
' Set a reference to the FileSaveAs object.
Dim oFileSaveAs As FileSaveAs
Set oFileSaveAs = oApprentice.FileSaveAs
' Save the assembly.
Call oFileSaveAs.AddFileToSave(oDoc, oDoc.FullFileName)
Call oFileSaveAs.ExecuteSave

Report

Re: change Referance file name VBA

hi
you must generate C:\Temp\Assembly1.iam (include oldpart.ipt) then you must generate newpart.ipt on C:\Temp\
if you do thıs it is run
maybe you have add referance to vba6 "autodesk inventor's appreance object library"

No comments:

Post a Comment