Message 1 of 5
iLogic, Save Placed Part in Active Assembly File Location

Not applicable
09-14-2015
09:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I couldn't seem to find exactly what I was looking for. For Piping, I am trying to insert an adaptive pipe part from a part library into a top level assembly and then, with iLogic, save the new Pipe part in the same location as the assembly (not the original pipe part location which is located in a custom parts library).
What I have so far works perfectly as far as automatically naming the file and everything, but it is saving to a subfolder where the original Pipe part is located. How can I get the top assembly file location and save there instead?
I have found similar posts, but I couldn't quite get those suggestions to work for me. Some guidence would be much appreciated. Below is the code I have so far.
Thanks
Dim oNewFileName As String Dim oNewFileNameAndPath As String Dim oPipeSuffix As Integer = 1 'Get active document path. In this case, the Custom Part Library part file, not the top assembly file location... 'How do I get the active assembly location which I am placing the part??? oActiveFileLoc=ThisDoc.Path 'Initialize File Name and Path oNewFileName = "P" & oPipeSuffix oNewFileNameAndPath = oActiveFileLoc & "\Pipe\" & oNewFileName & ".ipt" 'Check if File name already exists, increment suffix until filename is available (e.g. P1 x 4.5, P2 x 4.5, etc) While System.IO.File.Exists(oNewFileNameAndPath) oPipeSuffix = oPipeSuffix + 1 oNewFileName = "P" & oPipeSuffix oNewFileNameAndPath = oActiveFileLoc & "\Pipe\" & oNewFileName & ".ipt" End While 'For debugging MsgBox("File location" & vbLf & oActiveFileLoc & vbLf & vbLf & "File name" & vbLf & oNewFileName) 'Save document with the new available file name - Will later be set to "False" (Save as/load new). ThisDoc.Document.SaveAs(oNewFileNameAndPath, True)