The following iLogic code is to populate the first view scale into the title block. There are two issues with this code that I need help with. First, it requires there to be a prompted entry text box in the title block named <SCALE>, is there any way to write to a textbox that is not prompted entry? The prompt when a new drawing or sheet is created is misleading and makes users think they need to manually fill out the prompt. Secondly, this code works on multi-sheet drawings but it concludes by making the last sheet active. Since we are triggering this rule before save it's a nuisance to have the drawing switch sheets everytime you do a save. Ideally, the current active sheet should remain active when the rule runs. Here is the code:
For Each oSheet In ThisApplication.ActiveDocument.Sheets
ActiveSheet=ThisDrawing.Sheet(oSheet.Name)
If oSheet.TitleBlock Is Nothing Or oSheet.DrawingViews.count=0 Then Exit Sub
oTitleBlock=oSheet.TitleBlock
oTextBoxes=oTitleBlock.Definition.Sketch.TextBoxes
For Each oTextBox In oTextBoxes
If oTextBox.Text="<SCALE>" Then
DrawingViewName=ThisApplication.ActiveDocument.ActiveSheet.DrawingViews.Item(1).Name
oTitleBlock.SetPromptResultText(oTextBox, ActiveSheet.View(DrawingViewName).ScaleString)
End If
Next
Next
ThisApplication.ActiveDocument.Sheets.Item(1).Activate
InventorVb.DocumentUpdate()
Hi,
1) Yes, I think that Prompted Entry is the only thing that you can change on a per Title Block instance basis. If you modfied a text in the Title Block definition that would be reflected in each sheet that is using that definition.
2) You can simply store the currently active sheet and then reactivate it
store it at the beginning: actSheet = ThisApplication.ActiveDocument.ActiveSheet
.. and reactive it at the end: actSheet.Activate()
Also, you could create a Rule or Macro that the user could run to add a new sheet and that could add the TitleBlock with the Prompted Entry's filled in so that no dialog box would come up.
I hope this helps.
Cheers,
I'm trying to do something similar via iLogic...
Old drawings = get prompted entry data, update iprop field with this data, insert new titleblock
New drawings = update reivsed titleblock
I've got the old drawings iLogic working fine.... unless there are no prompted entries
Which I get the same issue with new drawings because there are no prompted entries.
Instead of having two different iLogic rules, I want to incorporate into one.
How can I do a search for any prompted entries
- if yes, run old drawings ilogic
- if no, revise title block
Here is the code I currently have that give me an error: (Public member 'Text' on type 'TextBoxes' not found.)
Dim oPromptText
Dim oEachText
Dim I
oEachText = oTB1.Definition.Sketch.TextBoxes
If (oEachText.Text = "Drawn By") Then
For I = 1 To oTB1.Definition.Sketch.TextBoxes.Count
oEachText = oTB1.Definition.Sketch.TextBoxes(I)
If (oEachText.Text = "Drawn By") Then ' found the prompt text we want to copy
oPromptText = oEachText
Exit For
End If
Next I
'get the result string of the prompt text
Dim oPromptEntry