Check whether the Sketch is Auxiliary

Check whether the Sketch is Auxiliary

Maxim-CADman77
Advisor Advisor
762 Views
11 Replies
Message 1 of 12

Check whether the Sketch is Auxiliary

Maxim-CADman77
Advisor
Advisor

When creating Sheet Metal flanges (and probably in some other cases) Inventor does create some sketches by itself.

Those sketches are not visible in the model tree thus let me call them "auxiliary".

I need ьн app treat those auxiliary sketches separately from others (skip).

How could I separate them from normal sketches (those user can edit directly)?

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
763 Views
11 Replies
Replies (11)
Message 2 of 12

Maxim-CADman77
Advisor
Advisor
Dim oCompdef As PartComponentDefinition
oCompdef = ThisDoc.Document.ComponentDefinition
Dim MsgBody As String
Dim AboveEoP_SkCount As Integer=0 
For each oSketch As Sketch in oCompDef.Sketches
	If oSketch.HealthStatus<>HealthStatusEnum.kBeyondStopNodeHealth then 
		AboveEoP_SkCount=AboveEoP_SkCount+1
		MsgBody=MsgBody & "                     " & oSketch.Name & vbCrLf
	Else
Exit For
	End If
Next
MsgBox (MsgBody,,"Out of " & oCompDef.Sketches.Count & " sketches " & AboveEoP_SkCount & " are placed above EoP:     ")

Безымянный.png

See attached IPT.

Sketch1 to my mind is normal

Sketch2 to my mind is auxiliary.

How could I sort them out?

 

Thanks in advance

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 3 of 12

Maxim-CADman77
Advisor
Advisor

Any Ideas, please...

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 12

YuhanZhang
Autodesk
Autodesk

The "auxiliary" sketch is created by the feature, now they should not be accessible via API in latest Inventor(I don't check from which Inventor we hide it from API), but if your Inventor still can get it via API, I suggest to check its IsOwnedByFeature to see if this returns True, you can ignore the sketches which is created by feature.

 

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 12

Maxim-CADman77
Advisor
Advisor

You are right regarding latest versions (2018 don't "see" auxiliary Sketch at all)

yet... Inventor 2014 returns False value of IsOwnedByFeature for all sketches (seems not very useful property). 

 

Dim oCompdef As PartComponentDefinition
oCompdef = ThisDoc.Document.ComponentDefinition
Dim MsgBody As String
Dim AboveEoP_SkCount As Integer=0 
For Each oSketch As Sketch In oCompDef.Sketches
	If oSketch.HealthStatus<>HealthStatusEnum.kBeyondStopNodeHealth Then 
		AboveEoP_SkCount=AboveEoP_SkCount+1
		MsgBody=MsgBody & "                     " & oSketch.Name & " - " & oSketch.IsOwnedByFeature & vbCrLf
	Else
Exit For
	End If
Next
MsgBox (MsgBody,,"Out of " & oCompDef.Sketches.Count & " sketches " & AboveEoP_SkCount & " are placed above EoP:     ")

I guess you then have no other recommendation but move to newest Inventor, right?

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 6 of 12

Maxim-CADman77
Advisor
Advisor

I wonder if it possible to use absence of auxiliary sketch in browser tree (haven't found the particular way yet)?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 7 of 12

Maxim-CADman77
Advisor
Advisor

I think its worth to dig in the direction of re-checking Sketch visibility in browser.

Till now I can read only first-level browser nodes:

Dim oDoc As Document
oDoc = ThisDoc.Document
Dim oTopNode As BrowserNode
oTopNode = oDoc.BrowserPanes.ActivePane.TopNode
Dim MsgBody As String
' Dim TotBN_Count As Integer=0 ' total 1st level nodes Count
Dim VisBN_Count As Integer=0 ' visible 1st level nodes Count
For Each oNode As BrowserNode In oTopNode.BrowserNodes
	TotBN_Count=TotBN_Count+1
	' Trace.WriteLine("iLogicVB" & oNode.FullPath)
	if oNode.Visible then VisBN_Count=VisBN_Count+1 : MsgBody=MsgBody & Right(oNode.FullPath,Len(oNode.FullPath)-(Len(oTopNode.FullPath)+1)) & VBcrlf
Next
MsgBox(MsgBody,,oTopNode.FullPath & " has " & VisBN_Count &" visible 1st-level nodes:    ")

Could somebody help to expand this code to get lidt of all visible nodes (mean after "expand all" command).

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 8 of 12

YuhanZhang
Autodesk
Autodesk

Can you try below code if it helps:

 

Dim oCompdef As PartComponentDefinition
oCompdef = ThisDoc.Document.ComponentDefinition

Dim oPane As BrowserPane
oPane = ThisDoc.Document.BrowserPanes("PmDefault")
    
Dim MsgBody As String
Dim AboveEoP_SkCount As Integer=0
For Each oSketch As Sketch In oCompDef.Sketches
    
    Dim oNode As BrowserNode
    oNode = oPane.GetBrowserNodeFromObject(oSketch)
    
    If oNode.Visible And oSketch.HealthStatus <> HealthStatusEnum.kBeyondStopNodeHealth Then
        SkCount = AboveEoP_SkCount + 1
        MsgBody = MsgBody & "                     " & oSketch.Name & " - " & oSketch.IsOwnedByFeature & vbCrLf
    Else
        Exit For
    End If
Next
MsgBox (MsgBody,,"Out of " & oCompDef.Sketches.Count & " sketches " & AboveEoP_SkCount & " are placed above EoP:     ")


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 9 of 12

Maxim-CADman77
Advisor
Advisor

I'm getting HRESULT: 0x80004005  if attempt to run this on B123W511111.ipt.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 10 of 12

Maxim-CADman77
Advisor
Advisor

How do I modify my latest code to get not only 1st level browser nodes?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 11 of 12

YuhanZhang
Autodesk
Autodesk
Accepted solution

Does the error happen to the line:

oNode = oPane.GetBrowserNodeFromObject(oSketch)

 

If so seems the browser node for the hidden sketch is not available, so you can try below code:

 

Dim oCompdef As PartComponentDefinition
oCompdef = ThisDoc.Document.ComponentDefinition

Dim oPane As BrowserPane
oPane = ThisDoc.Document.BrowserPanes("PmDefault")
    
Dim MsgBody As String
Dim AboveEoP_SkCount As Integer=0
For Each oSketch As Sketch In oCompdef.Sketches
	On Error Resume Next
    Dim oNode As BrowserNode
    oNode = oPane.GetBrowserNodeFromObject(oSketch)
    
	If Err.Number=0 Then
	    If oSketch.HealthStatus <> HealthStatusEnum.kBeyondStopNodeHealth Then
	        SkCount = AboveEoP_SkCount + 1
	        MsgBody = MsgBody & "                     " & oSketch.Name & " - " & oSketch.IsOwnedByFeature & vbCrLf
	    Else
	        Exit For
	    End If
	Else
		Err.Clear 
		On Error GoTo 0
	End If
Next
MsgBox (MsgBody,,"Out of " & oCompdef.Sketches.Count & " sketches " & AboveEoP_SkCount & " are placed above EoP:     ")

If you want to get the deeper level browser nodes, you can iterate the BrowserNode.BrowserNodes. But if the browser node for the sketch is not available you may not find it via API.

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 12 of 12

Maxim-CADman77
Advisor
Advisor

For older Inventor versions (ex. 2014) this code will return only real sketches (skip auxiliary):

Dim oCompdef As PartComponentDefinition
oCompdef = ThisDoc.Document.ComponentDefinition
Dim oPane As BrowserPane
oPane = ThisDoc.Document.BrowserPanes("PmDefault")
Dim MsgBody As String
Dim RealSketchCount As Integer=0
For Each oSketch As Sketch In oCompdef.Sketches
	On Error Resume Next
    Dim oNode As BrowserNode
    oNode = oPane.GetBrowserNodeFromObject(oSketch)
If Err.Number=0 Then If oSketch.HealthStatus <> HealthStatusEnum.kBeyondStopNodeHealth Then RealSketchCount=RealSketchCount + 1 MsgBody = MsgBody & oSketch.Name & vbCrLf End If End If Next MsgBox (MsgBody,,"Out of " & oCompdef.Sketches.Count & " sketches " & RealSketchCount & " are real: ")

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes