Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Count of revmarks in the sketch symbol

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
tonythm
194 Views, 5 Replies

Count of revmarks in the sketch symbol

Hello friends,

Every time I make a revision for a drawing, there are many revmarks marked. I have to count it manually and sometimes I miss it. I am thinking about ilogic or vba which can count the number of revmarks in the sketch symbol. Please help me. Thank you.

tonythm_0-1713879728669.png

 

5 REPLIES 5
Message 2 of 6
WCrihfield
in reply to: tonythm

Hi @tonythm.  I am not sure I understand the situation fully yet.  Are you saying that you use a SketchedSymbol instead of a regular revision tag every time you mark something as being revised?  And are you saying that the same, pre-existing SketchedSymbol on the sheet from the previous revision gets edited each time to add more geometry/text into that same SketchedSymbol for the next revision level, and you want code that can find this one SketchedSymbol, inspect the sketch defining that SketchedSymbol, and somehow determine how many of those internal revision symbols are within it?  This sounds very complicated...unless I am not understanding you correctly.

 

Or...are you using normal revision tags, and just want some code to count how many of those there are within your drawing?  Or...are you using a SketchedSymbol instead of a normal revision tag, but there is only one revision tag type spec within each SketchedSymbol, and you want to count how many of these special SketchSymbol objects are in your drawing that represent these revision tag alternatives?

Please explain as clearly as possible, and with as much detail as possible.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6
tonythm
in reply to: WCrihfield

@WCrihfield 

 

Thank you for your interest.

I am using SketchedSymbol instead of the usual revision tag,
In SketchedSymbol I use the Edit Property Field function to fill in revision A or B or C... and I want to count how many of these SketchSymbol objects are in the drawing.
Suppose, my current drawing is revision "B" and I am working on revision "C", then the drawing already has SketchedSymbols "B", how do I add SketchedSymbols "C" to know how many SketchedSymbols "C" there are, and each time I want to know how many SketchedSymbols "..." were recently added.

I just started using ilogic so I may not understand them very well.

Sub Main()
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oSymbol As SketchedSymbolDefinition
Dim REVMARK As String
Dim sData As String
Dim oCountB As Integer
Dim oCountC As Integer
For Each oSymbol In oDoc.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries
	If oSymbol.Name = "REVMARK" Then
		sData = oSymbol.GetResultText(oSymbol.Definition.Sketch.TextBoxes.Item(1))
		If sData = "B" Then
			oCountB = oDoc.SketchedSymbolDefinitions.Count
		End If
	End If
Next
MessageBox.Show(oCountB, "QUANTITY")
End Sub

 

Message 4 of 6
tonythm
in reply to: WCrihfield

Hi @WCrihfield 

I changed ilogic a bit, it displays all SketchedSymbols including SketchedSymbol revisions and SketchedSymbol others. How do I know how many latest SketchedSymbol revisions there are?

 

Sub Main()
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oSymbol As SketchedSymbol
Dim REVMARK As String
Dim sData As String
Dim oCountB As Integer
Dim oCountC As Integer
For Each oSymbol In oSheet.SketchedSymbols
	If oSymbol.Name = "REVMARK" Then
		sData = oSymbol.GetResultText(oSymbol.Definition.Sketch.TextBoxes.Item(1))
		If sData = "B" Then
			oCountB = oSheet.SketchedSymbols.Count
		End If
	End If
	'MessageBox.Show(oCountB, "QUANTITY")
Next
MessageBox.Show(oCountB, "QUANTITY")
End Sub
Message 5 of 6
WCrihfield
in reply to: tonythm

Hi @tonythm.  Here is another example iLogic rule you can try for this task.  Not really sure what type of output / results you are looking for, so I am must using MsgBox messages to show results.  We could also write the results to the iLogic Log window, if you wanted.

Sub Main
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Return
	Dim oSSDefs As SketchedSymbolDefinitions = oDDoc.SketchedSymbolDefinitions
	If oSSDefs.Count = 0 Then Return
	Dim oSSDef As SketchedSymbolDefinition
	Try : oSSDef = oSSDefs.Item("REVMARK") : Catch : End Try
	If oSSDef Is Nothing Then
		MsgBox("SketchedSymbolDefinition Named 'REVMARK' Not Found!", vbCritical, "iLogic")
		Return
	End If
	'assuming that it only has 1 TextBox, and that one is for a 'Prompted Entry'
	Dim oTB1 As Inventor.TextBox = oSSDef.Sketch.TextBoxes.Item(1)
	Dim oSheets As Inventor.Sheets = oDDoc.Sheets
	Dim oDict As New Dictionary(Of String, Integer)
	For Each oSheet As Inventor.Sheet In oSheets
		Dim oSSs As SketchedSymbols = oSheet.SketchedSymbols
		If oSSs.Count = 0 Then Continue For
		For Each oSS As SketchedSymbol In oSSs
			If oSS.Definition Is oSSDef Then
				Dim sResult As String = oSS.GetResultText(oTB1)
				If oDict.ContainsKey(sResult) Then
					oDict.Item(sResult) = oDict.Item(sResult) + 1
				Else
					oDict.Add(sResult, 1)
				End If
			End If
		Next 'oSS
	Next 'oSheet
	If oDict.Count = 0 Then
		MsgBox("No Rev SketchedSymbols Found In Drawing.", vbInformation, "iLogic")
	Else
		For Each oEntry In oDict
			MsgBox("There were " & oEntry.Value.ToString & " instances for Rev " & oEntry.Key)
		Next 'oEntry
	End If
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)

Message 6 of 6
tonythm
in reply to: WCrihfield

Hi @WCrihfield 

Exactly, this is what I need.

Thank you very much.

You are so excellent.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report