Determine if Marks are on the A-side

Determine if Marks are on the A-side

jzarczynski
Advocate Advocate
362 Views
5 Replies
Message 1 of 6

Determine if Marks are on the A-side

jzarczynski
Advocate
Advocate

Hi,

Due to our manufacturing process, we need to ensure that all marks created on a part are on the A-side of the sheet metal flat pattern.

 

My concept was to detect the A-side face and the face where the mark was created.

 

 

If markFeatures.Count > 0 Then
        If sheetMetalComp.FlatPattern IsNot Nothing Then
            Dim flatPattern As FlatPattern = sheetMetalComp.FlatPattern

            If flatPattern.ASideFace IsNot Nothing Then
                Dim asideDef As ASideDefinition = flatPattern.ASideFace
                Dim asideFace As Face = asideDef.ASideFace
                Dim marksOnASide As Integer = 0
               
                For Each markFeature As MarkFeature In markFeatures
                     ' There so property in Markfeature i can Use
                    Dim markFace As Face = MarkFeature.
                    If asideFace.EntityName = markFace.EntityName Then
                        marksOnASide += 1
                    End If
                Next

 

 

However, when reviewing MarkFeature properties, I do not see anything I can use to detect this:

 

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=GUID-MarkFeature

 

Could you advise if there is any possible approach to overcome this issue?

 

0 Likes
Accepted solutions (1)
363 Views
5 Replies
Replies (5)
Message 2 of 6

R.Mabery
Advocate
Advocate

Hi @jzarczynski,

 

Have you looked at the FindUsingRay method?  You should be able to get the face that the Mark Feature is on this way and determine if that's the A Side face.  

 

FYI, I haven't worked this out in code yet..... but the FindUsingRay method works well.


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
0 Likes
Message 3 of 6

nstevelmans
Advocate
Advocate

Hi, maybe you can try this I do check on the TransientKey.

  1. make list of all TransientKey from the flatpattern
  2.  make a list of all transientKey from the markFeature.
  3. Then do a compare.
 Dim oDoc As Document = ThisApplication.ActiveDocument
        Dim oAsideFaces As New List(Of Long)
        Dim oMarkFaces As New List(Of Long)
        If oDoc IsNot Nothing Then
            If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
                Dim oPartDoc As PartDocument = oDoc
                If oPartDoc.ComponentDefinition.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then
                    Dim oSheetMetalCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
                    Dim oFlattPatternExist As Boolean = oSheetMetalCompDef.HasFlatPattern
                    If oFlattPatternExist = True Then
                        Dim oFlatPattern As FlatPattern = oSheetMetalCompDef.FlatPattern
                        Dim oAsideFace As ASideDefinition = oFlatPattern.ASideFace
                        Dim oFace As Face = Nothing
                        For Each oFace In oAsideFace.Faces
                            oAsideFaces.Add(oFace.TransientKey)
                        Next
                        Dim oFeatures As SheetMetalFeatures = oSheetMetalCompDef.Features
                        Dim oMarkFeature As MarkFeature = Nothing
                        For Each oMarkFeature In oSheetMetalCompDef.Features.MarkFeatures
                            For Each oFace In oMarkFeature.Faces
                                oMarkFaces.Add(oFace.TransientKey)
                                Dim commonNames = oAsideFaces.Intersect(oMarkFaces).ToArray()
                                If commonNames.Length = 0 Then
                                    MsgBox("Ckeck your part")
									exit sub
                                End If
                            Next
                        Next
                    End If
                End If
            End If
        End If

 

If a response answers your question, please use  ACCEPT SOLUTION  to assist other users later.

 

Also be generous with Likes!  Thank you and enjoy!

 

0 Likes
Message 4 of 6

rlutesD2P6K
Participant
Participant
Accepted solution

I ended up solving this exact problem a couple months ago.

 

Below is a snippet of a much larger, complex laser checker code. You'll have to ignore some of the custom stuff going on, but this functions well. I haven't heard of any false positives or negatives since this was implemented.

 

We have two styles, a "etch" and a "through" cut, so we need to check for that. (through cuts can be on either side without a problem) You will need to check both the folded and flat patterns to be thorough, as designers can screw that up separately.

 

 

			'check if etch is on wrong side in folded model
			Try
			If tPart.Def.features.markfeatures.count > 0 Then 'if mark exists
				For Each tfeature In tPart.Def.features.markfeatures 'for each mark feature in folded model
					TDef = Tfeature.Definition 'get details of the mark feature
					Tstyle = TDef.markgeometrysetitem(1).style 'find which style its using
					If Tstyle.name = "Mark Surface" 'we only care if its a mark surface - etch
						Tgeom = TDef.markgeometrysetitem(1).geometries 'get geometry that generates it
						MarkSketch = tgeom(1).parent 'get sketch that creates geometry
						Try
						MarkFace = MarkSketch.planarentity 'get the face the mark works on
						flattenFace = oFP.getflatpatternentity(MarkFace) 'convert it to the flat pattern equivelent
						If flattenFace Is oFP.bottomface Then 'if the flat pattern equivelent is the bottom face of the flat pattern
							If ErrorAndOpen(tPart.Path,"has etches on the wrong side!") Then
							LaserChecker = True
							Exit Function
							End If
						End If
						Catch
							If ErrorAndOpen(tPart.Path,"has etches that aren't on the part!") Then
							LaserChecker = True
							Exit Function
							End If
						End Try
				End If
				Next
			End If	
			'check if etch is on wrong side in flat pattern
			If oFP.FEATURES.markfeatures.COUNT > 0 Then
				For Each Tfeature In oFP.FEATURES.markfeatures
					TDef = Tfeature.Definition
					Tstyle = TDef.markgeometrysetitem(1).style
					If Tstyle.name = "Mark Surface"
						Tgeom = TDef.markgeometrysetitem(1).geometries
						MarkSketch = tgeom(1).parent
						flattenface = MarkSketch.planarentity 'same as above, but skip the flat pattern equivelent step
						If flattenFace Is oFP.bottomface Then
							If errorandopen(tPart.Path,"has etches On the wrong side!") Then
								LaserChecker = True
								Exit Function
							End If
						End If
					End If
				Next
			End If

 

 

Message 5 of 6

jzarczynski
Advocate
Advocate

Thank you so much for your help.
After quite a long break, I came back to this problem and revisited your post from the thread:

https://forums.autodesk.com/t5/inventor-programming-ilogic/mark-feature-determine-if-feature-is-fron...

Following your guidance and the code you provided, I was finally able to get my solution working. The only difference in my approach is that I compare the internal names of the faces rather than the face objects themselves (it did not work).

 

Private Sub CheckMarksAgainstASide(ByVal partDef As SheetMetalComponentDefinition, ByVal markFeatures As MarkFeatures)
    Dim aSideFace As Face = partDef.FlatPattern.TopFace
    
    ' Case 1: Single mark
    If markFeatures.Count = 1 Then
        Dim markFeature As MarkFeature = markFeatures.Item(1)
        Dim markDef As Object = markFeature.Definition
        Dim geometrySet As MarkGeometrySet = markDef.MarkGeometrySetItem(1)
        Dim markSketchType As Object = geometrySet.Geometries(1)
        Dim markSketch As PlanarSketch = markSketchType.Parent
        
        'If TypeOf sketch Is PlanarSketch Then
        ' Mark sketch face
        Dim markSketchFace As Face = markSketch.PlanarEntity
        ' Mark sketch face flat pattern equivalent
        Dim flatPatternMarkSketchFace = partDef.FlatPattern.GetFlatPatternEntity(markSketchFace)
        
        'MsgBox(flatPatternMarkSketchFace.InternalName)
        'MsgBox(aSideFace.InternalName)
        
        If flatPatternMarkSketchFace.InternalName.Equals(aSideFace.InternalName) Then
            MsgBox("Engraving is on side A.")
        Else
            MsgBox("Warning! The engraving is not on side A of the sheet!")
        End If
        'End If
    Else
        ' Case 2: Multiple marks
        Dim nonASideFound As Boolean = False
        
        For i As Integer = 1 To markFeatures.Count
            Dim markFeature As MarkFeature = markFeatures.Item(1)
            Dim markDef As Object = markFeature.Definition
            Dim geometrySet As MarkGeometrySet = markDef.MarkGeometrySetItem(1)
            Dim markSketchType As Object = geometrySet.Geometries(1)
            Dim markSketch As PlanarSketch = markSketchType.Parent
            
            'If TypeOf sketch Is PlanarSketch Then
            ' Mark sketch face
            Dim markSketchFace As Face = markSketch.PlanarEntity
            ' Mark sketch face flat pattern equivalent
            Dim flatPatternMarkSketchFace = partDef.FlatPattern.GetFlatPatternEntity(markSketchFace)
            
            If Not flatPatternMarkSketchFace.InternalName.Equals(aSideFace.InternalName) Then
                MsgBox("Warning! At least one engraving is not on side A!")
                nonASideFound = True
                Exit For
            End If
            'End If
        Next
        
        If Not nonASideFound Then
            MsgBox("All engravings are on side A.")
        End If
    End If
End Sub

 



0 Likes
Message 6 of 6

_dscholtes_
Advocate
Advocate

If the only difference between the single mark / multiple mark is the end message to the user, I'd suggest to move the mark count check to there. This way you can have one single block of code do all the checking (both single and multiple marks using the for-loop of case 2) and one block handling the user message depending on the amount of marks and the check results. This improves readability and maintainability.


Or you could always use the plural form in your end message, no matter the amount of marks. I think the English language allows for that (style wise).

0 Likes