Saving a part that is changing in length by ilogic rule with new name in the new folder

ejafari82LVK
Participant
Participant

Saving a part that is changing in length by ilogic rule with new name in the new folder

ejafari82LVK
Participant
Participant

Hi,

I Have a base part that I use in a assembly (like frame generator with different Lengths)and with ilogic code I  change the length and I like to  save a part with new name before any changes and then change the new  part as I have to use this base part many times. I dont know how to do that , would you help me?

Reply
203 Views
3 Replies
Replies (3)

FINET_Laurent
Advisor
Advisor

Hello @ejafari82LVK,

 

Here is a small piece of code that you can put inside the part document you want to copy. This will copy the part to a new document with the desired name :

Dim doc As Inventor.Document = ThisApplication.ActiveDocument
Dim fullName As String = doc.FullFileName

Dim newName As String = InputBox("New part name :", "Define new file name")
If newName = "" Then Exit Sub
	
Dim index As Integer = fullName.LastIndexOf("\")
Dim path As String = Left(fullName, index + 1)

Dim newFileName As String = path & newName & ".ipt"

If IO.File.Exists(newFileName) = True Then 
	MsgBox("File already exists!")
	Exit Sub
	
End If
	
doc.SaveAs(newFileName, True	)
ThisApplication.Documents.Open(newFileName)

 

The part will land inside the same directory that the main part is located. If you want otherwise, please clarify how the directories are organised.

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

0 Likes

ejafari82LVK
Participant
Participant

Hello, Thanks for your solution. There is a problem, I don't want any massage box .I want it to do it automatically.

I have a Frame member with 1 inch length, I like to have more numbers of it  with different Lengths. Every time that I bring this member before any change I like to create a new part with a new name then I can edit the new part in length. 

 

 

Thanks

0 Likes

ejafari82LVK
Participant
Participant

 I have a frame that does not have constant dimensions (the top will change and even the height will change according to  the Form that I will create . As you see there are dimensions  "DLO" , the number of DlOs will vary and also the height of them and also the width of the frame  like frame generator  I have a mullion that is an ilogic part that can be changed in height but the length is 10 mm . 

so I like every time that opens this assembly the form ask about the dimension of the frame the the type of the mullion for each side of the frame and  create some new parts with the base mullion but with different lengths according to  the size of the frame. 

As I dont want the base mullion changes, so I have to save all this new parts and also this assembly with new names.

 

Thank you,

Elmira

0 Likes