Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selecting Save As directory with iLogic?

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
ThijsdZ
5280 Views, 19 Replies

Selecting Save As directory with iLogic?

Hi all,

 

I am making some iLogic automated parts which I want to save when I place them in an assembly.

Now I have the folder the file needs to be saved in allready specified in the simple code I wrote but I want to be able to browse the folders to select a specific one.

I run the code by activating it in a Form that pops up when you place the part in an assembly.

 

The simple save as code I wrote is as following:

 

Workspace = ThisDoc.WorkspacePath()
If System.IO.File.Exists(Workspace & "\Parts\" & "Cable Tray-" & Partnumber & ".ipt") = True Then
i = MessageBox.Show("The partnumber you chose is allready in use, choose an other number.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Else If System.IO.File.Exists(Workspace & "\Parts\" & "Cable Tray-" & Partnumber & ".ipt") = False Then
ThisDoc.Document.SaveAs(Workspace & "\Parts\" & "Cable Tray-" & Partnumber & ".ipt", False)
End If

 

Can someone tell me how I can browse the folders to select the folder to save the part in when placing the part?

 

 

Thanks in advance,

Thijs

19 REPLIES 19
Message 2 of 20
Curtis_Waguespack
in reply to: ThijsdZ

Hi ThijsdZ,

 

I think this should work for you:

 

oDoc = ThisDoc.Document

Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
If oDoc.DocumentType = kPartDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"
Else if oDoc.DocumentType = kAssemblyDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
Else if oDoc.DocumentType = kDrawingDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw"
End If
oFileDlg.InitialDirectory = ThisDoc.WorkspacePath()
oFileDlg.FileName = iProperties.Value("Project", "Part Number")
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowSave()
If Err.Number <> 0 Then
MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
ElseIf oFileDlg.FileName <> "" Then
MyFile = oFileDlg.FileName
oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As
End If

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 3 of 20
ThijsdZ
in reply to: Curtis_Waguespack

Thank you very much! It works very well.

There is just 1 thing I would like to be different if it is possible.

When the screen pops up the name that is selected to save the file as is the normal Partname it allready has.

But since the name is a Library name I use and the number of times I use it in a project is large I want it to take on the name I specified in my previous code ( "Cable Tray-" & Partnumber ).

The partnumber is a user parameter that is also editted in the form before you run the save rule.

Is it possible to get this name as standard name when opening the Save window?

 

Thanks in advance,

Thijs

Message 4 of 20
Curtis_Waguespack
in reply to: ThijsdZ

Hi ThijsdZ,

 

Unless I'm misunderstanding, you can just change:

 

oFileDlg.FileName = iProperties.Value("Project", "Part Number")

 

to:

oFileDlg.FileName = "Cable Tray-" & Partnumber

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 5 of 20
ThijsdZ
in reply to: ThijsdZ

Thank you very much for your help, that is just what I needed.

Message 6 of 20
GavoGarmo
in reply to: ThijsdZ

Hi There,

 

I think this is exactly what I'm looking for but I'm not sure. 🙂 The work flow I'm aiming for is:

 

Place iLogic Part  ==> Open Form on Placement ==> Description code be generated based on the specification ==> The .ipt is then saved in a specific directory, with the description code as the filename ==> Then the form becomes 'locked' and uneditable.

 

I'm basically trying to create a way for our desingers to pull in cupboard doors of any size, but build up a common library of files that can be reused by our CADCAM tooling department.

 

Cheers

 

GavoGarmo 

Message 7 of 20
GavoGarmo
in reply to: GavoGarmo

Actually, if it were editable, but did a save as with the updated filename/description, that would be better.

Message 8 of 20
Carl_mgfx
in reply to: GavoGarmo

Hi

 

I have a similar workflow to this which I need help with.  When a part is placed in an assembly I need to have the save as dialog box shown so that the file can be saved with a new name and placed into the assembly with this new name.    It will work very similar to the code above however the code needs to run when the part is placed into an assembly (an assembly template can be setup with the rule already in it).

 

Is this possible with iLogic?


Kind Regards
Carl van Rooyen
Application Engineer

Inventor 2019, Vault 2019,
HP ZBook 15u G4, Win 10 64Bit (ver 1709), i7-7500U, 16 GB Ram
Intel HD Graphics 620 with AMD Firepro W4190M
Message 9 of 20
ThijsdZ
in reply to: ThijsdZ

For me it runs when I place the part containing the Rule by adding an Event Trigger to the Rule.

I put the Rule in the 'After Open Document' Event, this means it will run when you open the file, but also when you place it in an assembly.

It wont run again when you open the assembly which you've placed the part in, only when you open the part itself.

Message 10 of 20
Carl_mgfx
in reply to: ThijsdZ

Thanks for the prompt reply.  I will try it tomorrow when I get in to work and let you know if it worked.


Kind Regards
Carl van Rooyen
Application Engineer

Inventor 2019, Vault 2019,
HP ZBook 15u G4, Win 10 64Bit (ver 1709), i7-7500U, 16 GB Ram
Intel HD Graphics 620 with AMD Firepro W4190M
Message 11 of 20
Carl_mgfx
in reply to: ThijsdZ

Hi ThijsdZ

 

I can't seem to get it working, this is what I have done.

 

I have placed the rule in my part file (Ring.ipt).

In my part file I created the rule trigger (see attached)

I then place the part in the assembly (Test.iam) and nothing happens.

 

Smiley Frustrated


Kind Regards
Carl van Rooyen
Application Engineer

Inventor 2019, Vault 2019,
HP ZBook 15u G4, Win 10 64Bit (ver 1709), i7-7500U, 16 GB Ram
Intel HD Graphics 620 with AMD Firepro W4190M
Message 12 of 20
ThijsdZ
in reply to: Carl_mgfx

Does the Rule run when you just open the file?
In my file I let the event trigger run a rule which opens a form, and it always opens when I place the part in an assembly.
The save as rule is then run by clicking on a button in this form.

But it should also work to just let the save as rule run at placing the part.
Message 13 of 20
Carl_mgfx
in reply to: ThijsdZ

I found where the problem is.

 

I had already placed the part in the assembly then added the trigger.  So when I tried to place the part again it had already been opened so the trigger does not run.

 

This trigger will only run for the first instance of the part placed into an assembly, for any duplicates the trigger and rule won't run because the part is already open.  The same applies for an assembly that is opened with the part already in it, as the assembly is opened the rule is triggered and duplicate parts placed in the assembly don't trigger the rule.

 

I would like the rule triggered for each part placed in the assembly regardless of it being a duplicate or not.  I will create a form and see if I can have the form show on placement of a part as you have it.

 

I hope this explanation is clear.


Kind Regards
Carl van Rooyen
Application Engineer

Inventor 2019, Vault 2019,
HP ZBook 15u G4, Win 10 64Bit (ver 1709), i7-7500U, 16 GB Ram
Intel HD Graphics 620 with AMD Firepro W4190M
Message 14 of 20
JBerns
in reply to: Carl_mgfx

I was testing this code in an external rule for Inventor 2019, but needed to open a file instead of save.

 

I changed the 'SaveAs' command to 'Open', but the file was not opening.

 

I had to change the code:

 

from:   oDoc.Open(MyFile, False)

to:     ThisApplication.Documents.Open(MyFile, False)

I hope this is helpful to others.

 

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 15 of 20

Hi, @Curtis_Waguespack. What is wrong with this macro? Because when I run to call the idw, but don't save the file idw.

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Assembly Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument

Dim oFileDlg As Inventor.FileDialog = Nothing
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
oFileDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
oFileDlg.FileName = ThisDoc.FileName(False)
oFileDlg.DialogTitle = "Specify New Name & Location For Copied Assembly"
oFileDlg.CancelError = True

On Error Resume Next
oFileDlg.ShowSave
If Err.Number <> 0 Then
	MsgBox("No File Saved.", vbOKOnly, "DIALOG CANCELED")
ElseIf oFileDlg.FileName <> "" Then
	oNewFileName = oFileDlg.FileName
	oADoc.SaveAs(oNewFileName, False)
End If

oADoc = Nothing

InventorVb.DocumentUpdate()

oADoc = ThisApplication.ActiveDocument

Dim oLast3Chars As String
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
	ThisApplication.Documents.Open(oRefDoc.FullFileName,False)
	oLast3Chars = Left(Right(oRefDoc.FullFileName, 7), 3)
	If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
		Dim oRefPDoc As PartDocument = oRefDoc
		Dim oRefPDef As PartComponentDefinition = oRefPDoc.ComponentDefinition
		If oRefPDef.IsContentMember = False Then
			oRefDoc.SaveAs(Left(oADoc.FullFileName, Len(oADoc.FullFileName) -4) & oLast3Chars & ".ipt", True)
		End If
	ElseIf oRefDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		oRefDoc.SaveAs(Left(oADoc.FullFileName, Len(oADoc.FullFileName) -4) & oLast3Chars & ".iam", True)
	End If
	oRefDoc.Close
Next

Dim oOccDoc As Document
Dim oOccNewFileName As String
For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences
	oOccDoc = oOcc.Definition.Document
	oLast3Chars = Left(Right(oOccDoc.FullFileName, 7), 3)
	If oOccDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
		Dim oOccPDef As PartComponentDefinition = oOcc.Definition
		If oOccPDef.IsContentMember = False Then
			oOccNewFileName = Left(oADoc.FullFileName, Len(oADoc.FullFileName) -4) & oLast3Chars & ".ipt"
		End If
	ElseIf oOccDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		oOccNewFileName = Left(oADoc.FullFileName,Len(oADoc.FullFileName)-4) & oLast3Chars & ".iam"
	End If
	oOcc.Replace(oOccNewFileName, True)
	
oDoc = ThisApplication.ActiveDocument
'oDoc = ThisDoc.Document
oDoc.DocumentType = kDrawingDocumentObject
oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw"
oFileDlg.InitialDirectory = ThisDoc.WorkspacePath()
oFileDlg.FileName = iProperties.Value("Project", "Part Number")
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowSave()
If Err.Number <> 0 Then
MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
ElseIf oFileDlg.FileName <> "" Then
MyFile = oFileDlg.FileName
oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As
End If
Next
Message 16 of 20

Hi @aronmatheus ,

 

It wasn't entirely clear what you were trying to accomplish, but this example creates copies of all the models and any associated drawings if found.

 

It expects to find the associated drawings in the same folder, with the same name as the models.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Assembly Documents.", vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oADoc As AssemblyDocument 
oADoc = ThisApplication.ActiveDocument
oName = ThisDoc.FileName(False) 'without extension
oPath = ThisDoc.Path

Dim oFileDlg As Inventor.FileDialog = Nothing
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
oFileDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
oFileDlg.FileName = ThisDoc.FileName(False)
oFileDlg.DialogTitle = "Specify New Name & Location For Copied Assembly"
oFileDlg.CancelError = True

Try
	oFileDlg.ShowSave
Catch
	MsgBox("No File Saved.", vbOKOnly, "DIALOG CANCELED")
	Return 'exit rule
End Try

If oFileDlg.FileName <> "" Then
	oNewFileName = oFileDlg.FileName
	oADoc.SaveAs(oNewFileName, False)
End If

oADoc = ThisApplication.ActiveDocument
oADocFullName = oADoc.FullFileName

'[ process top level drawing
oNewFileName = IO.Path.GetFileNameWithoutExtension(oADocFullName)
oNewFilePath = IO.Path.GetDirectoryName(oADocFullName)

oOldDrawingName = oPath & "\" & oName & ".idw"
oNewDrawingName = oNewFilePath & "\" & oNewFileName & ".idw"

Logger.Info(oOldDrawingName)
Logger.Info(oNewDrawingName)
Logger.Info("")


Try
	oDrawDoc = ThisApplication.Documents.Open(oOldDrawingName, False)
Catch
End Try

If Not oDrawDoc Is Nothing Then
	oDrawDoc.SaveAs(oNewDrawingName, False) 'True = Save As Copy & False = Save As
	oDrawDoc.close
End If
']


Dim oOccDoc As Document
Dim oOccNewFileName As String
For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences

	'[ process occurence documents
	oOccDoc = oOcc.Definition.Document
	oOccFullName = oOccDoc.FullFileName
	oLast3Chars = Left(Right(oOccDoc.FullFileName, 7), 3)
	oNewFileName = Left(oADocFullName, Len(oADocFullName) -4) & oLast3Chars

	If oOccDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
		Dim oOccPDef As PartComponentDefinition = oOcc.Definition
		If oOccPDef.IsContentMember = False Then
			oOccNewFileName = oNewFileName & ".ipt"
			oOccDoc.SaveAs(oOccNewFileName, True)
		End If
	ElseIf oOccDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		oOccNewFileName = oNewFileName & ".iam"
		oOccDoc.SaveAs(oOccNewFileName, True)
	End If

	oOcc.Replace(oOccNewFileName, True)
	']

	'[ process drawings
	oName = IO.Path.GetFileNameWithoutExtension(oOccFullName)
	oPath = IO.Path.GetDirectoryName(oOccFullName)
	oOldDrawingName = oPath & "\" & oName & ".idw"
	oNewDrawingName = oNewFileName & ".idw"

	Logger.Info(oOldDrawingName)
	Logger.Info(oNewDrawingName)

	Try
		oDrawDoc = ThisApplication.Documents.Open(oOldDrawingName, False)
	Catch
	End Try

	If oDrawDoc Is Nothing Then Continue For

	oDrawDoc.SaveAs(oNewDrawingName, False) 'True = Save As Copy & False = Save As
	oDrawDoc.close
	']

Next

 

Message 17 of 20

Hi @Curtis_Waguespack , there is a mistake in this ruler because save one body only, not all bodies are saving.

 

aronmatheus_0-1626284481578.png

 

Message 18 of 20
aronmatheus
in reply to: aronmatheus

Hi @Curtis_WaguespackI combined your rule with another one and attached it below, however, I can't break the link between the original files by copying the files to the new folder.

 

Captura de tela 2021-07-15 141546.png

'define the active document
oDoc = ThisDoc.Document

CurrentFileName = ThisDoc.PathAndFileName(False)

'create a file dialog box
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)

Dim Filetype As String

'check file type and set dialog filter
If oDoc.DocumentType = kPartDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Part Files (*.ipt)|*.ipt"
Filetype = ".ipt"
ElseIf oDoc.DocumentType = kAssemblyDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
Filetype = ".iam"
ElseIf oDoc.DocumentType = kDrawingDocumentObject Then
oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw"
Filetype = ".idw"
End If

'set the directory to open the dialog at
oFileDlg.InitialDirectory = ThisDoc.WorkspacePath()
'set the file name string to use in the input box
oFileDlg.FileName = ThisDoc.FileName(False) 'without extension

'work with an error created by the user backing out of the save
oFileDlg.CancelError = True
On Error Resume Next
'specify the file dialog as a save dialog (rather than a open dialog)
oFileDlg.ShowSave()

'catch an empty string in the imput
If Err.Number <> 0 Then
'MessageBox.Show("No File Saved.", "iLogic: Dialog Canceled")
ElseIf oFileDlg.FileName <> "" Then
MyFile = oFileDlg.FileName
'save the file
oDoc.SaveAs(MyFile, False) 'True = Save As Copy & False = Save As

NewDocPathName = ThisDoc.PathAndFileName(False)

'open original drawing
oDestinationDoc = ThisApplication.Documents.Open(CurrentFileName & ".idw")
oDestinationDoc.saveas(NewDocPathName & ".idw",False)
oDestinationDoc.Close

'open new drawing
oDestinationDoc = ThisApplication.Documents.Open(NewDocPathName & ".idw")
Dim oDocDescriptor As DocumentDescriptor
oDocDescriptor = oDestinationDoc.ReferencedDocumentDescriptors.Item(1)

Dim oFileDescriptor As FileDescriptor
oFileDescriptor = oDocDescriptor.ReferencedFileDescriptor

oFileDescriptor.ReplaceReference(NewDocPathName & Filetype)
oDestinationDoc.Update()
oDestinationDoc.Save
End If
InventorVb.DocumentUpdate()

oADoc = ThisApplication.ActiveDocument

Dim oLast3Chars As String
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
ThisApplication.Documents.Open(oRefDoc.FullFileName,False)
oLast3Chars = Left(Right(oRefDoc.FullFileName, 7), 3)
If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim oRefPDoc As PartDocument = oRefDoc
Dim oRefPDef As PartComponentDefinition = oRefPDoc.ComponentDefinition
If oRefPDef.IsContentMember = False Then
oRefDoc.SaveAs(Left(oADoc.FullFileName, Len(oADoc.FullFileName) -4) & oLast3Chars & ".ipt", True)
End If
End If
oRefDoc.Close
Next
Dim oOccDoc As Document
Dim oOccNewFileName As String
For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences
oOccDoc = oOcc.Definition.Document
oLast3Chars = Left(Right(oOccDoc.FullFileName, 7), 3)
If oOccDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Dim oOccPDef As PartComponentDefinition = oOcc.Definition
If oOccPDef.IsContentMember = False Then
oOccNewFileName = Left(oADoc.FullFileName, Len(oADoc.FullFileName) -4) & oLast3Chars & ".ipt"
End If
End if
oOcc.Replace(oOccNewFileName, True)
Next

Message 19 of 20

Hi @aronmatheus 

 

It appears I omitted some things in the version I posted in message 16.

 

here are some test file (Inventor 2019) and the revised code.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Assembly Documents.", vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oADoc As AssemblyDocument
oADoc = ThisApplication.ActiveDocument
oName = ThisDoc.FileName(False) 'without extension
oPath = ThisDoc.Path

Dim oFileDlg As Inventor.FileDialog = Nothing
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Autodesk Inventor Assembly Files (*.iam)|*.iam"
oFileDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
oFileDlg.FileName = ThisDoc.FileName(False)
oFileDlg.DialogTitle = "Specify New Name & Location For Copied Assembly"
oFileDlg.CancelError = True

Try
	oFileDlg.ShowSave
Catch
	MsgBox("No File Saved.", vbOKOnly, "DIALOG CANCELED")
	Return 'exit rule
End Try

If oFileDlg.FileName <> "" Then
	oNewFileName = oFileDlg.FileName
	oADoc.SaveAs(oNewFileName, False)
End If

oADoc = ThisApplication.ActiveDocument
oADocFullName = oADoc.FullFileName

'[ process top level drawing
oNewFileName = IO.Path.GetFileNameWithoutExtension(oADocFullName)
oNewFilePath = IO.Path.GetDirectoryName(oADocFullName)

oOldDrawingName = oPath & "\" & oName & ".idw"
oNewDrawingName = oNewFilePath & "\" & oNewFileName & ".idw"

Logger.Info(oOldDrawingName)
Logger.Info(oNewDrawingName)
Logger.Info("")


Try
	oDrawDoc = ThisApplication.Documents.Open(oOldDrawingName, False)
Catch
End Try

If Not oDrawDoc Is Nothing Then
	oDrawDoc.SaveAs(oNewDrawingName, False) 'True = Save As Copy & False = Save As

	Dim oFD As FileDescriptor
	oFD = oDrawDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
	oFD.ReplaceReference(oADocFullName)
	oDrawDoc.save
	oDrawDoc.close
End If
']


Dim oOccDoc As Document
Dim oOccNewFileName As String
For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences

	'[ process occurence documents
	oOccDoc = oOcc.Definition.Document
	oOccFullName = oOccDoc.FullFileName
	oLast3Chars = Left(Right(oOccDoc.FullFileName, 7), 3)
	oNewFileName = Left(oADocFullName, Len(oADocFullName) -4) & oLast3Chars

	If oOccDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
		Dim oOccPDef As PartComponentDefinition = oOcc.Definition
		If oOccPDef.IsContentMember = False Then
			oOccNewFileName = oNewFileName & ".ipt"
			oOccDoc.SaveAs(oOccNewFileName, True)
		End If
	ElseIf oOccDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
		oOccNewFileName = oNewFileName & ".iam"
		oOccDoc.SaveAs(oOccNewFileName, True)
	End If

	oOcc.Replace(oOccNewFileName, True)
	']

	'[ process drawings
	oName = IO.Path.GetFileNameWithoutExtension(oOccFullName)
	oPath = IO.Path.GetDirectoryName(oOccFullName)
	oOldDrawingName = oPath & "\" & oName & ".idw"
	oNewDrawingName = oNewFileName & ".idw"

	Logger.Info(oOldDrawingName)
	Logger.Info(oNewDrawingName)

	Try
		oDrawDoc = ThisApplication.Documents.Open(oOldDrawingName, False)
	Catch
	End Try

	If oDrawDoc Is Nothing Then Continue For

	oDrawDoc.SaveAs(oNewDrawingName, False) 'True = Save As Copy & False = Save As

	Dim oFD As FileDescriptor
	oFD = oDrawDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
	oFD.ReplaceReference(oOccNewFileName)

	oDrawDoc.save
	oDrawDoc.close
	']

Next


http://inventortrenches.blogspot.com

Message 20 of 20

Hi @Curtis_Waguespack. Is it possible for me to save the image using your rule?

 

Part number.png

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

Post to forums  

Autodesk Design & Make Report