Prompt Entry Read needed in code.

Prompt Entry Read needed in code.

BVasquez78MGR
Participant Participant
506 Views
3 Replies
Message 1 of 4

Prompt Entry Read needed in code.

BVasquez78MGR
Participant
Participant

I'm kind of new at coding. Can someone help me? Right now, my SHEET # is linked to the browser name. How do I attach the field text, SHEET #, to modify this code below? 

BVasquez78MGR_0-1669840391975.png 

 

This is the outcome I need to accomplish in the end.

BVasquez78MGR_1-1669841226025.png

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view.")
If oView IsNot Nothing Then
	If  oView.ViewType = DrawingViewTypeEnum.kDetailDrawingViewType Then
		oDView = oView
		oOrigName = oDView.Name
		oDView.Name = oOrigName & "/ MU-8005"
		oDView.Label.FormattedText = "DETAIL " & oOrigName & "<Br/>SCALE <DrawingViewScale/>"
	End If
	Else
		MsgBox("The selected View's Scale is set by the Base View, and can't be changed this way.", vbOKOnly + vbExclamation, " ")
	End If

 

0 Likes
Accepted solutions (1)
507 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @BVasquez78MGR 

 

I think this will get what you are after.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oDDoc As DrawingDocument = ThisDrawing.Document

Dim oTBlock  As TitleBlock
oTBlock = oDDoc.ActiveSheet.TitleBlock

Dim oTBlockDef As TitleBlockDefinition
oTBlockDef = oTBlock.Definition
Dim oTextBox As TextBox

' Find the Prompted Entry called <MATERIALS> in the Title Block
For Each oTextBox_InTB_Def As TextBox In oTBlockDef.Sketch.TextBoxes
	'Logger.info(oTextBox_InTB_Def.Text)
    If oTextBox_InTB_Def.Text.Contains(UCase("SHEET #")) Then
        oTextBox = oTextBox_InTB_Def 
		sValue = oTBlock.GetResultText(oTextBox)	
		'MsgBox(sValue)
         Exit For              
    End If
Next    

Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view.")
If oView IsNot Nothing Then
	If oView.ViewType = DrawingViewTypeEnum.kDetailDrawingViewType Then
		oDView = oView
		oOrigName = oDView.Name
		oDView.Name = oOrigName & "/ " & sValue
		oDView.Label.FormattedText = "DETAIL " & oOrigName & "<Br/>SCALE <DrawingViewScale/>"
	End If
Else
	MsgBox("The selected View's Scale is set by the Base View, and can't be changed this way.", vbOKOnly + vbExclamation, " ")
End If

 

EESignature

0 Likes
Message 3 of 4

BVasquez78MGR
Participant
Participant

You are awesome, Obi-Wan Kanobi 😊;  it worked great!! It will be a lot more challenging to figure out how to reference another detail section with the same label from another page, which will be my next headache. Trying to use the same approach, pick a view and copy info to the new section view. Do you think this can be possible?

Message 4 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @BVasquez78MGR 

 

I didn't test it, but I think you would do something along these lines.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oDDoc As DrawingDocument = ThisDrawing.Document

Dim oTBlock  As TitleBlock
oTBlock = oDDoc.ActiveSheet.TitleBlock

Dim oTBlockDef As TitleBlockDefinition
oTBlockDef = oTBlock.Definition
Dim oTextBox As TextBox

' Find the Prompted Entry called <MATERIALS> in the Title Block
For Each oTextBox_InTB_Def As TextBox In oTBlockDef.Sketch.TextBoxes
	'Logger.info(oTextBox_InTB_Def.Text)
    If oTextBox_InTB_Def.Text.Contains(UCase("SHEET #")) Then
        oTextBox = oTextBox_InTB_Def 
		sValue = oTBlock.GetResultText(oTextBox)	
		'MsgBox(sValue)
         Exit For              
    End If
Next  

Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view.")
If oView IsNot Nothing Then
	If oView.ViewType = DrawingViewTypeEnum.kDetailDrawingViewType Then
		oDView = oView
		oOrigName = oDView.Name
		oDView.Name = oOrigName & "/ " & sValue
		oDView.Label.FormattedText = "DETAIL " & oOrigName & "<Br/>SCALE <DrawingViewScale/>"
	End If
Else
	MsgBox("The selected View's Scale is set by the Base View, and can't be changed this way.", vbOKOnly + vbExclamation, " ")
End If

Dim oSheet As Sheet
For Each oSheet In oDDoc.Sheets
	For Each oView In oSheet.DrawingViews
		If oView.Type = DrawingViewTypeEnum.kDetailDrawingViewType
			If oView.Name.Contains(oOrigName) Then
				oView.Name = oOrigName & "/ " & sValue
			End If
		End If
	Next
Next

	

 

EESignature

0 Likes