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: 

increasing a value to count

2 REPLIES 2
Reply
Message 1 of 3
matt_jlt
249 Views, 2 Replies

increasing a value to count

matt_jlt
Collaborator
Collaborator
I have the following code below, I am trying to determine the number of occurences of a symbol "Symbol 01". I can get the basic function to work i just dont know how to use a value "w" and increment it, any help is much appreciated. Thanks.

Public Sub SketchSymbolTest()

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSS As SketchedSymbol
Dim w As Long

Set oDoc = ThisApplication.ActiveDocument
Set oSheet = oDoc.ActiveSheet

For Each oSS In oSheet.SketchedSymbols

If oSS.Definition.Name = "Symbol 01" Then
' ### This is where i dont know what to do
End If

Next
MsgBox w, , " Occurences In this Document"
End Sub
0 Likes

increasing a value to count

I have the following code below, I am trying to determine the number of occurences of a symbol "Symbol 01". I can get the basic function to work i just dont know how to use a value "w" and increment it, any help is much appreciated. Thanks.

Public Sub SketchSymbolTest()

Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSS As SketchedSymbol
Dim w As Long

Set oDoc = ThisApplication.ActiveDocument
Set oSheet = oDoc.ActiveSheet

For Each oSS In oSheet.SketchedSymbols

If oSS.Definition.Name = "Symbol 01" Then
' ### This is where i dont know what to do
End If

Next
MsgBox w, , " Occurences In this Document"
End Sub
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: matt_jlt

Anonymous
Not applicable
I've modified your code to increment the counter. I also initialized the
counter w to zero. This isn't really needed since VB initializes value type
variable to 0, but not all languages do this and I think it makes the code
more readable.

Public Sub SketchSymbolTest()
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSS As SketchedSymbol
Dim w As Long

Set oDoc = ThisApplication.ActiveDocument
Set oSheet = oDoc.ActiveSheet

w = 0
For Each oSS In oSheet.SketchedSymbols
If oSS.Definition.Name = "Symbol 01" Then
w = w + 1
End If
Next
MsgBox w, , " Occurences In this Document"
End Sub
--
Brian Ekins
Autodesk Inventor API
0 Likes

I've modified your code to increment the counter. I also initialized the
counter w to zero. This isn't really needed since VB initializes value type
variable to 0, but not all languages do this and I think it makes the code
more readable.

Public Sub SketchSymbolTest()
Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSS As SketchedSymbol
Dim w As Long

Set oDoc = ThisApplication.ActiveDocument
Set oSheet = oDoc.ActiveSheet

w = 0
For Each oSS In oSheet.SketchedSymbols
If oSS.Definition.Name = "Symbol 01" Then
w = w + 1
End If
Next
MsgBox w, , " Occurences In this Document"
End Sub
--
Brian Ekins
Autodesk Inventor API
Message 3 of 3
matt_jlt
in reply to: matt_jlt

matt_jlt
Collaborator
Collaborator
thanks mate, worked like a charm.
0 Likes

thanks mate, worked like a charm.

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

Post to forums  

Autodesk Design & Make Report