04-12-2022
05:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
04-12-2022
05:17 AM
This should be what your looking for. First it goes through all reference docs and selects one with "cube.ipt" in its file path. Then it creates a copy of that naming it "my_custom_name". Then it makes a privite event to skip the dialog box. Then it runs the replace all cmd. Finally it refreshes the browser nodes.
Dim oAss As AssemblyDocument oAss = ThisApplication.ActiveDocument Dim oDoc As Document For Each oDoc In oAss.AllReferencedDocuments If InStr(oDoc.FullDocumentName, "cube.ipt") > 0 template = oDoc.FullDocumentName newlength = InStrRev(oDoc.FullDocumentName, "\") newfile = Left(template, newlength) & "my_custom_name.ipt" IO.File.Copy(template, newfile, True) oDocName = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullDocumentName) ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, newfile) compo = Component.InventorComponent(oDocName & ":1") oAss.SelectSet.Select(compo) Dim oReplaceCmd As ControlDefinition oReplaceCmd = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyReplaceAllCmd") oReplaceCmd.Execute Dim oRefreshNodes As ControlDefinition oRefreshNodes = ThisApplication.CommandManager.ControlDefinitions.Item("MoldRefreshBrowserNodes") oRefreshNodes.Execute End If Next