Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Title Block Link to Excel to Update Single Sheet in Multi-Sheet IDW

drafting4KGWTN
Participant

Title Block Link to Excel to Update Single Sheet in Multi-Sheet IDW

drafting4KGWTN
Participant
Participant

Hi everyone,

 

my company is toying with the idea of using multi-sheet drawings for assembly (and sometimes multi-assembly) jobs.

Currently I've got some code working that will update the title & revision block (all custom iprops) of a single-sheet IDW. Trouble is, i cant adapt this code to work for a multi-sheet drawing file. I've been scouring the forums trying to find any relevant code to help, but the issue is the same. Running the rule updates ALL the title blocks in the sheet-set, as opposed to just the active sheet which is what I need.

 

Any help would be greatly appreciated.

 

Please see below for the current working code for a single-sheet IDW file:

I've also attached a dummy excel file for any testing

 

StrNum = InputBox("Please enter the JMG DRAWING NUMBER", "titty block")

I = GoExcel.FindRow("S:\A - DRAWINGS\DRAFTING from 2022\DRAWING REGISTER\Inventor Registers\HVO inventor.xlsm.xlsx", "sheet1", "JMG DRAWING NUMBER", "-", StrNum)
StrTitle = GoExcel.CurrentRowValue("Title")
StrCompany = GoExcel.CurrentRowValue("Company")
StrDesc = GoExcel.CurrentRowValue("Description")
StrProject = GoExcel.CurrentRowValue("Project")
StrRevisionNumber = GoExcel.CurrentRowValue("Register Revision Number")
StrJMGDrawingNumber = GoExcel.CurrentRowValue("JMG DRAWING NUMBER")
StrClientDrawingNumber = GoExcel.CurrentRowValue("CLIENT DRAWING NUMBER")
StrRevNoLine1 = GoExcel.CurrentRowValue("REF DRAWING NUMBER LINE 1")
StrRevDesLine1 = GoExcel.CurrentRowValue("REF DRAWING DESCRIPTION LINE 1")
StrRevNoLine2 = GoExcel.CurrentRowValue("REF DRAWING NUMBER LINE 2")
StrRevDesLine2 = GoExcel.CurrentRowValue("REF DRAWING DESCRIPTION LINE 2")
StrRevNoLine3 = GoExcel.CurrentRowValue("REF DRAWING NUMBER LINE 3")
StrRevDesLine3 = GoExcel.CurrentRowValue("REF DRAWING DESCRIPTION LINE 3")
StrRevNoLine4 = GoExcel.CurrentRowValue("REF DRAWING NUMBER LINE 4")
StrRevDesLine4 = GoExcel.CurrentRowValue("REF DRAWING DESCRIPTION LINE 4")
StrRevNoLine5 = GoExcel.CurrentRowValue("REF DRAWING NUMBER LINE 5")
StrRevDesLine5 = GoExcel.CurrentRowValue("REF DRAWING DESCRIPTION LINE 5")
StrRefDesLine1 = GoExcel.CurrentRowValue("Rev L1 Description")
StrRefAppLine1 = GoExcel.CurrentRowValue("Rev L1 Approved")
StrRefByLine1 = GoExcel.CurrentRowValue("Rev L1 By")
StrRefNoLine1 = GoExcel.CurrentRowValue("Rev L1 Number")
StrDateLine1 = GoExcel.CurrentRowValue("Rev L1 Date")
StrRefDesLine2 = GoExcel.CurrentRowValue("Rev L2 Description")
StrRefAppLine2 = GoExcel.CurrentRowValue("Rev L2 Approved")
StrRefByLine2 = GoExcel.CurrentRowValue("Rev L2 By")
StrRefNoLine2 = GoExcel.CurrentRowValue("Rev L2 Number")
StrDateLine2 = GoExcel.CurrentRowValue("Rev L2 Date")
StrRefDesLine3 = GoExcel.CurrentRowValue("Rev L3 Description")
StrRefAppLine3 = GoExcel.CurrentRowValue("Rev L3 Approved")
StrRefByLine3 = GoExcel.CurrentRowValue("Rev L3 By")
StrDateLine3 = GoExcel.CurrentRowValue("Rev L3 Date")
StrRefNoLine3 = GoExcel.CurrentRowValue("Rev L3 Number")
StrRefDesLine4 = GoExcel.CurrentRowValue("Rev L4 Description")
StrRefAppLine4 = GoExcel.CurrentRowValue("Rev L4 Approved")
StrRefByLine4 = GoExcel.CurrentRowValue("Rev L4 By")
StrRefNoLine4 = GoExcel.CurrentRowValue("Rev L4 Number")
StrDateLine4 = GoExcel.CurrentRowValue("Rev L4 Date")
StrRefDesLine5 = GoExcel.CurrentRowValue("Rev L5 Description")
StrRefAppLine5 = GoExcel.CurrentRowValue("Rev L5 Approved")
StrRefByLine5 = GoExcel.CurrentRowValue("Rev L5 By")
StrRefNoLine5 = GoExcel.CurrentRowValue("Rev L5 Number")
StrDateLine5 = GoExcel.CurrentRowValue("Rev L5 Date")
StrRefDesLine6 = GoExcel.CurrentRowValue("Rev L6 Description")
StrRefAppLine6 = GoExcel.CurrentRowValue("Rev L6 Approved")
StrRefByLine6 = GoExcel.CurrentRowValue("Rev L6 By")
StrRefNoLine6 = GoExcel.CurrentRowValue("Rev L6 Number")
StrDateLine6 = GoExcel.CurrentRowValue("Rev L6 Date")

iProperties.Value("Custom", "Drawing Number") = StrNum
iProperties.Value("Summary", "Title") = StrTitle
iProperties.Value("Summary", "Company") = StrCompany
iProperties.Value("Project", "Description") = StrDesc
iProperties.Value("Project", "Project") = StrProject
iProperties.Value("Custom", "JMG DRAWING NUMBER") = StrJMGDrawingNumber
iProperties.Value("Project", "Part Number") = StrClientDrawingNumber
iProperties.Value("Project", "Revision Number") = StrRevisionNumber
iProperties.Value("Custom", "REF DRAWING NUMBER LINE 1") = StrRevNoLine1
iProperties.Value("Custom", "REF DRAWING DESCRIPTION LINE 1") = StrRevDesLine1
iProperties.Value("Custom", "REF DRAWING NUMBER LINE 2") = StrRevNoLine2
iProperties.Value("Custom", "REF DRAWING DESCRIPTION LINE 2") = StrRevDesLine2
iProperties.Value("Custom", "REF DRAWING NUMBER LINE 3") = StrRevNoLine3
iProperties.Value("Custom", "REF DRAWING DESCRIPTION LINE 3") = StrRevDesLine3
iProperties.Value("Custom", "REF DRAWING NUMBER LINE 4") = StrRevNoLine4
iProperties.Value("Custom", "REF DRAWING DESCRIPTION LINE 4") = StrRevDesLine4
iProperties.Value("Custom", "REF DRAWING NUMBER LINE 5") = StrRevNoLine5
iProperties.Value("Custom", "REF DRAWING DESCRIPTION LINE 5") = StrRevDesLine5
iProperties.Value("Custom", "Rev L1 Description") = StrRefDesLine1
iProperties.Value("Custom", "Rev L1 Approved") = StrRefAppLine1
iProperties.Value("Custom", "Rev L1 By") = StrRefByLine1
iProperties.Value("Custom", "Rev L1 Number") = StrRefNoLine1
iProperties.Value("Custom", "Rev L1 Date") = StrDateLine1
iProperties.Value("Custom", "Rev L2 Description") = StrRefDesLine2
iProperties.Value("Custom", "Rev L2 Approved") = StrRefAppLine2
iProperties.Value("Custom", "Rev L2 By") = StrRefByLine2
iProperties.Value("Custom", "Rev L2 Number") = StrRefNoLine2
iProperties.Value("Custom", "Rev L2 Date") = StrDateLine2
iProperties.Value("Custom", "Rev L3 Description") = StrRefDesLine3
iProperties.Value("Custom", "Rev L3 Approved") = StrRefAppLine3
iProperties.Value("Custom", "Rev L3 By") = StrRefByLine3
iProperties.Value("Custom", "Rev L3 Number") = StrRefNoLine3
iProperties.Value("Custom", "Rev L3 Date") = StrDateLine3
iProperties.Value("Custom", "Rev L4 Description") = StrRefDesLine4
iProperties.Value("Custom", "Rev L4 Approved") = StrRefAppLine4
iProperties.Value("Custom", "Rev L4 By") = StrRefByLine4
iProperties.Value("Custom", "Rev L4 Number") = StrRefNoLine4
iProperties.Value("Custom", "Rev L4 Date") = StrDateLine4
iProperties.Value("Custom", "Rev L5 Description") = StrRefDesLine5
iProperties.Value("Custom", "Rev L5 Approved") = StrRefAppLine5
iProperties.Value("Custom", "Rev L5 By") = StrRefByLine5
iProperties.Value("Custom", "Rev L5 Number") = StrRefNoLine5
iProperties.Value("Custom", "Rev L5 Date") = StrDateLine5
iProperties.Value("Custom", "Rev L6 Description") = StrRefDesLine6
iProperties.Value("Custom", "Rev L6 Approved") = StrRefAppLine6
iProperties.Value("Custom", "Rev L6 By") = StrRefByLine6
iProperties.Value("Custom", "Rev L6 Number") = StrRefNoLine6
iProperties.Value("Custom", "Rev L6 Date") = StrDateLine6


MessageBox.Show("All properties have been applied to " & StrNum, "Success")

 

0 Likes
Reply
264 Views
5 Replies
Replies (5)

Ralf_Krieg
Advisor
Advisor

Hello

 

The titleblock on the sheet is just a reference to the titleblockdefinition. All titleblocks get the same informations. This is as designed. There is no way to update only one the way you try.

If you need different entries, you can either define a separate titleblockdefinition for each sheet and set custoim iProps according to each sheet. Or you use PromptedEntries instead iProp in your titleblock.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes

drafting4KGWTN
Participant
Participant

...our shop has too much variety to do custom iprops for every sheet. i'll have a look into the prompted entries you mentioned.

thank you for the reply

 

@drafting4KGWTN -this post has been edited due to Community Rules & Etiquette violation

0 Likes

drafting4KGWTN
Participant
Participant

I've been doing some digging today and found some code that does what i want. The only problem is, it loops through the prompt entries to each sheet in the IDW set.

after trial and error, i managed to alter the code so the loop stops after one sheet. But it'll only change the prompts on the 1st sheet - as opposed to the one that is active

 

please see below for both pieces of code

(code looping through each sheet)

Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheets As Inventor.Sheets = oDDoc.Sheets
For Each oSheet As Sheet In oSheets
	If oSheet.TitleBlock Is Nothing Then Continue For
	Dim oTB As TitleBlock = oSheet.TitleBlock
	Dim oSketch As DrawingSketch = oTB.Definition.Sketch
	Dim oTBoxes As Inventor.TextBoxes = oSketch.TextBoxes
	If oTBoxes.Count = 0 Then Continue For
	Dim sP1 As String = "<Prompt>" : Dim sP2 As String = "</Prompt>"
	For Each oTBox As Inventor.TextBox In oTBoxes
		If Not oTBox.FormattedText.Contains(sP2) Then Continue For
		Dim sPrompt As String = oTBox.Text.Substring(1, oTBox.Text.Length - 2)
		Dim sCurVal As String = oTB.GetResultText(oTBox)
		Dim sNewVal As String = InputBox(sPrompt, "Prompted Entry", sCurVal)
		oTB.SetPromptResultText(oTBox, sNewVal)
	Next 'oTBox

Next 'oSheet

code terminating after 1st cycle (but only writing to 1st sheet)

Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheets As Inventor.Sheets = oDDoc.Sheets
For Each oSheet As Sheet In oSheets
	If oSheet.TitleBlock Is Nothing Then Continue For
	Dim oTB As TitleBlock = oSheet.TitleBlock
	Dim oSketch As DrawingSketch = oTB.Definition.Sketch
	Dim oTBoxes As Inventor.TextBoxes = oSketch.TextBoxes
	If oTBoxes.Count = 0 Then Continue For
	Dim sP1 As String = "<Prompt>" : Dim sP2 As String = "</Prompt>"
	For Each oTBox As Inventor.TextBox In oTBoxes
		If Not oTBox.FormattedText.Contains(sP2) Then Continue For
		Dim sPrompt As String = oTBox.Text.Substring(1, oTBox.Text.Length - 2)
		Dim sCurVal As String = oTB.GetResultText(oTBox)
		Dim sNewVal As String = InputBox(sPrompt, "Prompted Entry", sCurVal)
		oTB.SetPromptResultText(oTBox, sNewVal)
	Next 'oTBox

		If oSheet IsNot oActiveSheet Then
	Exit Sub

End If

Next 'oSheet

 

0 Likes

jnowel
Advocate
Advocate

if you only need to change the Activesheet, better to just define oSheet as such instead of having a For Loop.

Dim oSheet as Sheet  = oDDoc.ActiveSheet

 

And you would have to replace the previous oSheet For Loop's "Continue For" to, possibly, "Exit sub" 

 

0 Likes

Stakin
Advocate
Advocate

If each sheet has different information,you couldn’t use the property of idw file.

it maybe a way to change or set properties for every sheet’s first view referenced model file.

 

0 Likes