Mark feature messes up loop count in iLogic

Mark feature messes up loop count in iLogic

ekaspar3JCGJ
Participant Participant
375 Views
3 Replies
Message 1 of 4

Mark feature messes up loop count in iLogic

ekaspar3JCGJ
Participant
Participant

Hi,

 

I am trying to use the Mark feature for the first time. I use an iLogic rule that gets total laser cutting length and number of pierces among other info. When I run my iLogic rule, it gets the distance of one loop of the Mark feature and nothing else. I am not very good at iLogic and am unable to determine why this is happening. I have determined this is directly related to the Mark feature, because if I place the mark on the non-A-Side it is ignored and the correct cutting length and pierce quantity is used. I don't care very much if the mark loops are or are not added to the loop length.

My code is pasted below, and attached is a sheet metal file I'm using it on as an example. Any help is greatly appreciated.

 

Sub Main
	
	Dim isdoc As Document = ThisDoc.Document
	If isdoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
		Exit Sub
	Else
		'Create custom iproperties
		customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
		
		Dim iprop(4) As String
		iprop(1) = "Cutting Length"
		iprop(2) = "Pierces"
		iprop(3) = "Bends"
		iprop(4) = "Weight"
		
		For k = 1 To 4
		Dim prop(k) As String
		    Try
		        prop(k) = iProperties.Value("Custom", iprop(k))
		    Catch
		        'Assume error means not found
		        customPropertySet.Add("", iprop(k))
		        iProperties.Value("Custom", iprop(k)) = "null"
		    End Try
		Next
		
		'Get cutting length
		Dim oSMDoc As PartDocument = ThisApplication.ActiveDocument
		Dim oSMDDef As SheetMetalComponentDefinition = oSMDoc.ComponentDefinition
		If oSMDDef.HasFlatPattern = False Then
			MsgBox("There is no Flat Pattern yet.", vbOKOnly, "NO FLAT PATTERN")
			Return
		End If
		Dim oTopFace As Face = oSMDDef.FlatPattern.TopFace
		Dim oMeasureTools As MeasureTools = ThisApplication.MeasureTools
		Dim oLoopLength As Double = 0
		For Each oEdgeLoop As EdgeLoop In oTopFace.EdgeLoops
			oLoopLength = oLoopLength + oMeasureTools.GetLoopLength(oEdgeLoop)
		Next
		oLoopLength = oLoopLength / 2.54
		oLoopLength = Round(oLoopLength, 2)

		'get bends
		Dim bendqty As Integer = oSMDDef.Bends.Count
		
		'get mass
		mass = Round(iProperties.Mass, 2)
	
		'get pierces
		TotalPierces = 1
		For Each oEdgeLoop In oSMDDef.FlatPattern.TopFace.EdgeLoops
		    If oEdgeLoop.IsOuterEdgeLoop = False Then
		        TotalPierces = TotalPierces + 1
		    End If
		Next
		
		'write data to iproperties
		iProperties.Value("Custom", "Pierces") = TotalPierces
		iProperties.Value("Custom", "Bends") = bendqty
		iProperties.Value("Custom", "Cutting Length") = oLoopLength
		iProperties.Value("Custom", "Weight") = mass & " LBS."
		
	End If
	End Sub

 

0 Likes
376 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Maybe your code could first check if there are any mark features in that part, and if there are, get their resulting edges in a collection before evaluating the laser pierces and cut lengths, so that you can check the edges along the way, to see if they belong to one of the mark features.  The MarkFeature object has ResultEdges method, for getting all of the edges that resulted from that feature as an Edges object.  If that was obtained first, then you could later inspect each Edge in the EdgeLoop.Edges to see if they belong to the mark feature.  If so, then skip that EdgeLoop.  Just a thought. 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

ekaspar3JCGJ
Participant
Participant

Thank you for the reply! The only problem that I think would persist is that for some reason it seems that the presence of the mark feature stops the edgeloop count from iterating? That seems to be the main problem, unless I'm misunderstanding how it all works (which is just as likely).

0 Likes
Message 4 of 4

ekaspar3JCGJ
Participant
Participant

For the record and for anyone else experiencing this problem, I did not find a way to fix this as I originally wished. My workaround is to suppress all mark features, run the block of code that counts edgeloops for cutting travel, then unsuppress the mark feature again. Kind of crude but it's working until I discover the real solution.

0 Likes