蒹葭苍苍,白露为霜。
所谓伊人,在水一方。

Inventor工程图批量替换文本-ilogic外部规则

有时候,你想批量替换工程图中的标准文本或指引线文本。那么可以试试如下的ilogic代码,可存为txt,然后应用外部规则。

  1: Dim oDoc As Document
  2: oDoc = ThisApplication.ActiveDocument
  3: 
  4: If oDoc.DocumentType = kDrawingDocumentObject Then
  5:     Dim oDwgDoc As DrawingDocument
  6:     oDwgDoc = ThisApplication.ActiveDocument
  7:     
  8:     Dim oSheet As Sheet
  9:     Dim oDwgView As DrawingView
 10:     Dim oSketch As Sketch
 11:     Dim oText As TextBox
 12:     
 13:     Dim oGenNot As GeneralNote
 14:     MyText = InputBox("What Text?", "Search Text")
 15:     If MyText = "" Then
 16:         MsgBox ("You input empty field, process canceling!")
 17:         Exit Sub
 18:     End If
 19:     NewText = InputBox("New Text?", "Modify Text")
 20:     
 21:     If NewText = "" Then
 22:         MsgBox ("You input empty field, process canceling!")
 23:         Exit Sub
 24:     End If
 25:     
 26:     For Each oSheet In oDwgDoc.Sheets
 27:         For Each oDwgView In oSheet.DrawingViews
 28:             For Each oSketch In oDwgView.Sketches
 29:                 For Each oText In oSketch.TextBoxes
 30:                     If oText.Text = MyText Then
 31:                         oSketch.Edit
 32:                         oText.FormattedText = NewText
 33:                         oSketch.ExitEdit
 34:                     End If
 35:                 Next
 36:             Next
 37:         Next
 38:         For Each oGenNot In oSheet.DrawingNotes.GeneralNotes
 39:             If oGenNot.Text = MyText Then
 40:                 oGenNot.FormattedText = NewText
 41:             End If
 42:         Next
 43:     Next
 44: Else
 45:     MsgBox ("Only for drawing document")
 46: End If

运行后,会提示要替换的文本,然后填入新文本。之后会全部替换掉。

无聊,搬运一下。

最近都没什么灵感,完了。

赞(2) 打赏
未经允许不得转载:酷居科技 » Inventor工程图批量替换文本-ilogic外部规则

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

锦瑟无端五十弦,一弦一柱思华年

酷居科技联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏