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

iLogic check drawing table

p.kaminskiG7KX4
Enthusiast

iLogic check drawing table

p.kaminskiG7KX4
Enthusiast
Enthusiast

Hello, 

I need some help. I would like to write a rule, that will check the drawing table to find some empty fields. I mean, if i forget to write quantity od the part, during closing the sheet, then error will appear with message " Fill Qty field", for example. The same with material, description etc.

Greetings

0 Likes
Reply
Accepted solutions (1)
795 Views
10 Replies
Replies (10)

tyler.warner
Advocate
Advocate

@p.kaminskiG7KX4  Are you talking about a parts list or general/custom table?

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes

WCrihfield
Mentor
Mentor

Are you talking about ensuring that specific iProperties have values set before saving the drawing?  What do you mean by 'drawing table'?  Do you mean that you have created a 'Custom Table' (using the Table tool), and you have to manually type values into its cells in certain places?  If it is a true Table, then is it linked to an Excel document or anything like that?  Are you talking about 'Prompted Entry' fields within your Title Block?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

p.kaminskiG7KX4
Enthusiast
Enthusiast

 

 


What I mean is that if there is no value in the table window, for example a quantity, then when I try to close the drawing I get the message "no quantity specified". I would like to do it in the form of a trigger. This is to act as a reminder to complete the missing information in the table.

 

0 Likes

tyler.warner
Advocate
Advocate

On the drawing file, under the Annotate tab, under the Table panel, which of these are you using for your table? Parts List? Hole? Revision? General?

 

tylerwarner_0-1675370784843.png

 

If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
0 Likes

p.kaminskiG7KX4
Enthusiast
Enthusiast

Table built into the template. Currently an introduction quantity values ​​can be done at startup (automatic triggering) or by editing the ISO table in the file tree.

 

Zrzut ekranu 2023-02-02 215856.jpgZrzut ekranu 2023-02-02 215952.jpg

0 Likes

WCrihfield
Mentor
Mentor

Hi @p.kaminskiG7KX4.  Thanks for posting the images.  That really helps us to understand what you are working on.  You are working on the title block of the drawing, and the pop-up dialog you are showing is where you can edit the 'Prompted Entries' within that title block.  We are now much closer to being able to help you with this.  The next thing we will need to know is which ones of those 'prompts' (the text on the left, side of the grid, within the pop-up dialog) is are the ones you want to check.  We would likely need to use the exact spelling and capitalization of the 'prompt' text, in order to find the TextBox objects within your title block's sketch that are for each of those prompts, then check their values (or fill them in by code, if you wanted).  Since all the text in that dialog appear to be in a language that I am not fluent in, and we can not see them all anyways, you may need to either list them here on the forum, or put them in a text file, then attach that text file.  It would also be very helpful if you could post a copy of one of your drawing files here, so that we can test out our proposed code solutions on it.  If you post a file, make sure you clear it of any personal or proprietary data.  There does not need to be any drawing views on it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

WCrihfield
Mentor
Mentor

This code will help you explore those prompted entries in your title block.  Something similar would be used for checking their values, or setting new values to them, if changed a bit, and customized to your specific needs.  It can be fairly complicated to automate those by code, unless extremely familiar with that specific drawing.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
		MsgBox("A Drawing Document must be active for this code to work. Exiting.", vbCritical, "")
		Exit Sub
	End If
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oSheet As Sheet = oDDoc.ActiveSheet
	If oSheet.TitleBlock Is Nothing Then
		MsgBox("There is no TitleBlock on the active sheet.  Exiting rule.", vbCritical,"")
		Exit Sub 'or Continue For if in a Loop
	End If
	Dim oTB As TitleBlock = oSheet.TitleBlock
	Dim oTBDef As TitleBlockDefinition = oTB.Definition
	Dim oSketchCopy As DrawingSketch = Nothing
	oTBDef.Edit(oSketchCopy)
	Dim oTBoxs As Inventor.TextBoxes = oSketchCopy.TextBoxes
	If oTBoxs.Count = 0 Then
		MsgBox("There are no TextBoxes in the TitleBlock.  Exiting rule.", vbCritical,"")
		Exit Sub
	End If
	For Each oTBox As Inventor.TextBox In oTBoxs
		Dim oResultText As String = ""
		Try
			oResultText = oTB.GetResultText(oTBox)
		Catch
			'MsgBox("GetResultText method failed.",,"")
		End Try
		MsgBox("Current TextBox Contents:" & vbCrLf & _
		"TextBox.Text = " & oTBox.Text & vbCrLf & _
		"TextBox.FormattedText = " & oTBox.FormattedText & vbCrLf & _
		"oResultText = " & oResultText, , "")
		'the following would be used to enter a new value for the 'Prompted Entry'
		'oTB.SetPromptResultText(oTBox, oNewResultStringValue)
	Next
	oTBDef.ExitEdit(False) 'False = don't save changes
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

p.kaminskiG7KX4
Enthusiast
Enthusiast

Here it is

0 Likes

tyler.warner
Advocate
Advocate
Accepted solution

@p.kaminskiG7KX4 you can try something like this. It is a modified version of the code above.

 

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
		MsgBox("A Drawing Document must be active for this code to work. Exiting rule.", vbCritical, "")
		Exit Sub
	End If
	
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oSheet As Sheet = oDDoc.ActiveSheet
	
	If oSheet.TitleBlock Is Nothing Then
		MsgBox("There is no TitleBlock on the active sheet. Exiting rule.", vbCritical,"")
		Exit Sub 'or Continue For if in a Loop
	End If
	
	Dim oTB As TitleBlock = oSheet.TitleBlock
	Dim oTBDef As TitleBlockDefinition = oTB.Definition
	Dim oSketchCopy As DrawingSketch = Nothing
	oTBDef.Edit(oSketchCopy)
	Dim oTBoxs As Inventor.TextBoxes = oSketchCopy.TextBoxes
	
	If oTBoxs.Count = 0 Then
		MsgBox("There are no TextBoxes in the TitleBlock. Exiting rule.", vbCritical,"")
		Exit Sub
	End If
		
	Dim oEmptyEntries As String = ""
	For Each oTBox As Inventor.TextBox In oTBoxs
		Dim oResultText As String = ""
		Try			
			oResultText = oTB.GetResultText(oTBox)
		Catch
			'MsgBox("GetResultText method failed.",,"")
		End Try
		
		If oTBox.FormattedText.Contains("</Property>") Or oTBox.FormattedText.Contains("</DerivedProperty>") Then
			If oResultText.Trim(" ") = "" Then
				oEntryName = oTBox.Text
				oEntryName = oEntryName.Trim(" ")
				oEntryName = oEntryName.Trim("<")
				oEntryName = oEntryName.Trim(">")
				oEmptyEntries = oEmptyEntries & vbNewLine & oEntryName
			End If
		End If
		
'		MsgBox("Current TextBox Contents:" & vbNewLine & vbNewLine & _
'		"TextBox.Text = " & oTBox.Text & vbNewLine & vbNewLine & _
'		"TextBox.FormattedText = " & oTBox.FormattedText & vbNewLine & vbNewLine & _
'		"oResultText = " & oResultText, , "")

		' The following would be used to enter a new value for the 'Prompted Entry'
		'oTB.SetPromptResultText(oTBox, oNewResultStringValue)
	Next
	oTBDef.ExitEdit(False) 'False = don't save changes
	
	MsgBox("There are empty entries in the Title Block." & vbNewLine & oEmptyEntries, vbExclamation, "Title Block Missing Entries")
End Sub
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.

p.kaminskiG7KX4
Enthusiast
Enthusiast

Thank you very much Mr. Tyler. This is exactly what I was looking for. This is very helpful. 

0 Likes