ilogic help

ilogic help

Josh_Metalogy
Enthusiast Enthusiast
282 Views
2 Replies
Message 1 of 3

ilogic help

Josh_Metalogy
Enthusiast
Enthusiast

I have a bit of iLogic code that works on flat patterns and I need some help adding a new function to it. On the bend note if there is a bend radius of 11/16 I need it to give me a field where I can say, "See forming guide." The full text should read, "<DIR> <ANGL> R <RAD> SEE FORMING GUIDE." Below is the rule I would like to add this functionality to. Thank you!

doc = ThisDoc.Document
For Each oSheet In doc.Sheets
  For Each oView In oSheet.DrawingViews
    If oView.IsFlatPatternView Then
	oView.ShowLabel = True 'Turn on view label
 'oFSize = .1 'font size, units unknown
 

                ViewLabel = oView.Name
			'clear current view label	
				oView.Label.FormattedText = ""
				
                oModelName = _
                oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
                Try
			oFSize = .1*2.54
            oMaterial = "<StyleOverride Underline='False'><Property Document='model' PropertySet='Design Tracking Properties' Property='Material' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
			oGauge = iProperties.Value(oModelName, "Custom", "ShtThk")
			oLength = iProperties.Value(oModelName, "Custom", "FlatLength")
			oWidth = iProperties.Value(oModelName, "Custom", "FlatWidth")
			oMaterial = iProperties.Value(oModelName, "Custom", "Material")
			'oName = iProperties.Value("Project", "Part Number") 'Only got the .idw file name
			oName = iProperties.Value(oModelName, "Custom", "FileName")
            'add the the iProperty to the current view label, with a dash separator
                oView.Label.FormattedText = "<StyleOverride FontSize='" & oFSize & "'>" & oMaterial & " - "& oGauge & vbCrLf & oLength & " x " & oWidth & vbCrLf & oName & "</StyleOverride>"
            'oOldLabel = oView.Label.Text
			'oView.Label.FormattedText = "<StyleOverride FontSize='" & oFSize & "'>" & oOldLabel & "</StyleOverride>"
			Catch
            'do nothing if error
                End Try
    End If
	If Not oView.IsFlatPatternView Then
	'	MsgBox("Not a Flat Pattern")
              
                'capture the current view label
                ViewLabel = oView.Name
							'clear current view label	
		'		oView.Label.FormattedText = "insert here"
                oModelName = _
                oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
               Try
            o_iProp = iProperties.Value(oModelName, "Project", "Part Number")        
            'add the the iProperty to the current view label, with a dash separator
               ' oView.Name = o_iProp
				oView.Label.FormattedText = o_iProp
            Catch
            'do nothing if error
                End Try
       
End If
  Next
Next

 

0 Likes
283 Views
2 Replies
Replies (2)
Message 2 of 3

CA_Wald
Explorer
Explorer

Can you check if this rule works?

 

doc = ThisDoc.Document

For Each oSheet In doc.Sheets
  For Each oView In oSheet.DrawingViews
    If oView.IsFlatPatternView Then
        oView.ShowLabel = True ' Turn on view label

        ViewLabel = oView.Name
        oView.Label.FormattedText = "" ' Clear current view label

        oModelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName

        Try
            oFSize = 0.1 * 2.54 ' font size in cm
            oGauge = iProperties.Value(oModelName, "Custom", "ShtThk")
            oLength = iProperties.Value(oModelName, "Custom", "FlatLength")
            oWidth = iProperties.Value(oModelName, "Custom", "FlatWidth")
            oMaterial = iProperties.Value(oModelName, "Custom", "Material")
            oName = iProperties.Value(oModelName, "Custom", "FileName")

            ' Get the model document
            Dim oModelDoc As PartDocument
            oModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

            ' Get flat pattern definition
            Dim oCompDef As SheetMetalComponentDefinition
            oCompDef = oModelDoc.ComponentDefinition

            ' Ensure flat pattern exists
            Dim oFlat As FlatPattern
            If oCompDef.HasFlatPattern Then
                oFlat = oCompDef.FlatPattern
            Else
                oCompDef.Unfold() ' <-- FIXED: Call method
                oFlat = oCompDef.FlatPattern
            End If

            ' Check if any bend radius = 11/16"
            Dim showFormingGuide As Boolean = False
            For Each oBend In oFlat.BendResults
                If Math.Round(oBend.Radius, 4) = 0.6875 Then
                    showFormingGuide = True
                    Exit For
                End If
            Next

            ' Construct view label
            Dim labelText As String
            labelText = oMaterial & " - " & oGauge & vbCrLf & oLength & " x " & oWidth & vbCrLf & oName

            If showFormingGuide Then
                labelText = labelText & vbCrLf & "<DIR> <ANGL> R <RAD> SEE FORMING GUIDE"
            End If

            oView.Label.FormattedText = "<StyleOverride FontSize='" & oFSize & "'>" & labelText & "</StyleOverride>"

        Catch
            ' Do nothing on error
        End Try

    Else
        ' Not a flat pattern view
        ViewLabel = oView.Name
        oModelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName

        Try
            o_iProp = iProperties.Value(oModelName, "Project", "Part Number")
            oView.Label.FormattedText = o_iProp
        Catch
            ' Do nothing on error
        End Try

    End If
  Next
Next
0 Likes
Message 3 of 3

Josh_Metalogy
Enthusiast
Enthusiast

Thank you for taking this on Wald. When I run this rule it will turn on the view label in flat patterns but the label is empty. Is it possible to put the forming guide note on the bend note that is 11/16 radius rather than in the view label? I ran it on a file that has the 11/16 radius.

0 Likes