Is there a macro to change text inside a sketched symbol that is already added to a drawing? I would like to run a macro that opens a drawing in inventor, while the drawing is open, it finds a specific sketch symbol and then edits specific text in that sketch symbol, and then saves the drawing and closes it. But I would like for it to process multiple drawings in a specified folder and also run and include all the drawings in its sub-folders. Does anyone have an idea on how to create this macro? Or already have this macro I can edit? Or even something similar that I can use for a starting point?
@Frederick_Law - this post has been edited due to Community Rules & Etiquette violation.
Easiest way is replace the "Sketched Symbol" with correct text.
I got old drawings with "Sketched Symbol" I need to replace from new Template.
This iLogic rule will delete "Borders", "Title Blocks" and "Sketch Symbols" in current drawing and then copy them from template: "Standard.idw".
It also sort Title Blocks and Sketch Symbols.
Sub Main()
'Update old files to match new templates
'ipt - Add View Rep: Default, Design
' Sync Style, Material
' Document Settings
'iam - Add View Rep: Default, Design
' BOM setting - hide suspensed parts
'idw - Sync Style
' Copy Drawing Resources
' SketchedSymbolDefinition.CopyTo(Target, ReplaceExisting)
' SketchedSymbolDefinition.CopyTo(Target, ReplaceExisting)
' Remember Border and Title Block on each sheet
' (Delete Borders and Title Blocks on all Sheets
' Delete all Drawing Resources) or set auto Overwrite
' Copy and Paste Drawing Resource from Standard.idw
' (Add Border and Title Block)
'ActiveSheet.TitleBlock = "My Title Block"
'idw Update
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTemplateDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSketchedSymbolDef As SketchedSymbolDefinition
Dim oTempSketchedSymbolDef As SketchedSymbolDefinition
Dim oSketchedSymbolDefs = oDrawDoc.SketchedSymbolDefinitions
Dim oBorderDef As BorderDefinition
Dim oTitleBlockDef As TitleBlockDefinition
Dim oTempBorderDef As BorderDefinition
Dim oTempTitleBlockDef As TitleBlockDefinition
Dim oBorderName As String
Dim oTitleblockName As String
'Get Current border and titleblock name
oBorderName = oDrawDoc.ActiveSheet.Border.Name
oTitleblockName = oDrawDoc.ActiveSheet.TitleBlock.Name
'Delete all used Border and Titleblock in each sheet
For Each oSheet In oDrawDoc.Sheets
'Dim oSheet = oDrawDoc.ActiveSheet
'Logger.Info(oBorderName)
'Logger.Info(oTitleblockName)
If oSheet.Border IsNot Nothing Then
oSheet.Border.Delete
End If
If oSheet.TitleBlock IsNot Nothing Then
oSheet.TitleBlock.Delete
End If
Next
'Delete everything in Drawing Resources
For Each oSketchedSymbolDef In oSketchedSymbolDefs
Try
oSketchedSymbolDef.Delete
Catch
End Try
Next
For Each oBorderDef In oDrawDoc.BorderDefinitions
oBorderDef.Delete
Next
For Each oTitleBlockDef In oDrawDoc.TitleBlockDefinitions
oTitleBlockDef.Delete
Next
'Get Drawing Resource from Template
oTemplateDoc = ThisApplication.Documents.Open("C:\Vault Workspace\Templates\Standard.idw",False)
For Each oTempBorderDef In oTemplateDoc.BorderDefinitions
'Logger.Info(oTempBorderDef.Name)
If oTempBorderDef.Name <> "Default Border" Then
oBorderDef = oTempBorderDef.CopyTo(oDrawDoc)
End If
Next
'Copy SketchSymbols
For Each oTempSketchedSymbolDef In oTemplateDoc.SketchedSymbolDefinitions
'Logger.Info(oTempSketchedSymbolDef.Name)
oTempSketchedSymbolDef.CopyTo(oDrawDoc,True)
Next
'Sort Sketched Symbols
'Select Browser "Sketch Symbols" node before Execute Sort
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Sketch Symbols").DoSelect
Call ThisApplication.CommandManager.ControlDefinitions.Item("DrawingResourceSort").Execute
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Sketch Symbols").Expanded = False
'Copy TitleBlock
For Each oTempTitleBlockDef In oTemplateDoc.TitleBlockDefinitions
'Logger.Info(oTempTitleBlockDef.Name)
oTempTitleBlockDef.CopyTo(oDrawDoc)
Next
'Sort Title Blocks
'Select Browser "Title Blocks" node before Execute Sort
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Title Blocks").DoSelect
Call ThisApplication.CommandManager.ControlDefinitions.Item("DrawingResourceSort").Execute
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Title Blocks").Expanded = False
oTemplateDoc.Close(True)
'Add original Border and TitleBlock
For Each oSheet In oDrawDoc.Sheets
oBorderDef = oDrawDoc.BorderDefinitions.Item(oBorderName)
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item(oTitleblockName)
oSheet.AddBorder(oBorderDef)
oSheet.AddTitleBlock(oTitleBlockDef)
Next
'Style Update
End Sub
Can't find what you're looking for? Ask the community or share your knowledge.