Using the SketchEntitiesEnumerator object in VB

Using the SketchEntitiesEnumerator object in VB

Anonymous
Not applicable
440 Views
1 Reply
Message 1 of 2

Using the SketchEntitiesEnumerator object in VB

Anonymous
Not applicable
I am writing an Add-In for inventor and one of the things I want to do is querry the open sketch for existing entities. If the number of entities is greater than 0, I want to send a message to the user. I have been trying to use the SketchEntitiesEnumerator.Count and have been unsuccessful. I can get the program to compile but when I test it in inventor it gets an error. What are the proper variable declarations to make this work?

In general I find the inventor help on the API to be somewhat cryptic. Can you recommend a book that deals with the API in depth?
0 Likes
441 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Here's a little sample that does what you asked
about.  The ActiveEditObject property of the Application will return
whatever object is currently being edited.

 

Public Sub
CheckSketch()
    If TypeOf ThisApplication.ActiveEditObject
Is Sketch Then
        Dim oSketch As
Sketch
        Set oSketch =
ThisApplication.ActiveEditObject
       

        If oSketch.SketchEntities.Count
> 0
Then
           
MsgBox "The active sketch contains some
geometry."
       
Else
           
MsgBox "The active sketch is
empty."
        End
If
    Else
       
MsgBox "A sketch is not active."
    End If
End
Sub


-Brian

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
am writing an Add-In for inventor and one of the things I want to do is querry
the open sketch for existing entities. If the number of entities is greater
than 0, I want to send a message to the user. I have been trying to use the
SketchEntitiesEnumerator.Count and have been unsuccessful. I can get the
program to compile but when I test it in inventor it gets an error. What are
the proper variable declarations to make this work?

In general I find the inventor help on the API to be somewhat cryptic. Can
you recommend a book that deals with the API in
depth?

0 Likes