iLogic Sketch Curve Counter

iLogic Sketch Curve Counter

jtylerbc
Mentor Mentor
1,115 Views
3 Replies
Message 1 of 4

iLogic Sketch Curve Counter

jtylerbc
Mentor
Mentor

Hello all, looking for a little help with an iLogic rule I'm working on.

 

Much of our work is structures fabricated from steel plate.  One of our practices is to add a note " (SK) " to the description of plates that have a detailed sketch somewhere in the fab drawing set (simple rectangular or circular plates with no addtional features do not get these detailed sketches).  The actual "detailed sketch" is just a dimensioned drawing view of that plate.

 

I've been working on automating this process so that Inventor can actually determine for the user whether or not the sketch is required.  I have it in certain part templates by default.  Other templates add the note automatically through iLogic when certain plate features are selected, or when the model consists of multiple part features.

 

This leaves one remaining case that the current set of rules can't catch - when the user creates cutouts, notches, etc. by modifying the sketch for the original extrusion.  I have determined a method for catching that case, but haven't yet figured out how to program it.

 

What I want to do is count all of the lines, arcs, and circles in the first model sketch.  If that count returns a number other than 4 lines, the note will be added.  If any arcs are detected, the note will be added.  If any circles are detected with lines also present, the note will be added.  There may be other cases that will come up in testing that need to be covered, but I ran into an issue before I got that far.  Construction geometry messes up the count - I need a way to exclude it.

 

Below is the test code I have so far for the counter.  Please let me know what techniques I can use to get construction geometry out of the count.  This code doesn't include the provisions for actually adding the note yet - I'm just trying to get the counter working right first.  Instead it's just displaying the total count in a message box for test purposes.

 

oDoc=ThisDoc.Document
oSketch=oDoc.ComponentDefinition.Sketches.Item(1)

LineCount=oSketch.Sketchlines.count
CircleCount=oSketch.SketchCircles.count
ArcCount=oSketch.SketchArcs.count

TotalCount=LineCount+CircleCount+ArcCount

MessageBox.Show("Total Count "&TotalCount, "Title")

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

Anonymous
Not applicable

jtylerbc,

 

I worked off of your sample code and came up with the following code in VBA. I will work on converting it to iLogic in the morning. Let me know how it works out.

 

I have a macro set up in document project of the attached file.

0 Likes
Message 3 of 4

Anonymous
Not applicable
Accepted solution

Here is the iLogic version of the above macro.

 

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oSketch As Sketch
oSketch = oDoc.ComponentDefinition.Sketches.Item(1)
Dim SketchCount As Double

Dim i As Double
    For i = 1 To oSketch.SketchLines.Count
        If oSketch.SketchLines.Item(i).Construction = "False" Then
            SketchCount = SketchCount + 1
        End If
    Next

Dim x As Double
    For x = 1 To oSketch.SketchCircles.Count
        If oSketch.SketchCircles.Item(x).Construction = "False" Then
            SketchCount = SketchCount + 1
        End If
    Next

Dim y As Double
    For y = 1 To oSketch.SketchArcs.Count
        If oSketch.SketchArcs.Item(y).Construction = "False" Then
            SketchCount = SketchCount + 1
        End If
    Next

MessageBox.Show(sketchcount, "Number of Sketch Curves")

 

 

0 Likes
Message 4 of 4

jtylerbc
Mentor
Mentor

I'll need to make some modifications to it (as I actually need a seperate count for line, arcs, and circles), but I think you've given me the missing piece I needed.  I knew there had to be a way to get the construction line status, but I was overlooking it.

 

Thanks.

0 Likes