Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor Drawing double break view iLogic

3 REPLIES 3
Reply
Message 1 of 4
Jacques.Grobler
1015 Views, 3 Replies

Inventor Drawing double break view iLogic

Hi All

 

I am trying to do a none / single / double break in a view depending on parameters fed to the model

 

I am able to delete the breaks and add a single break, now I am trying to modify it to be able to do a double break but I get the below error:

     Error in rule: ctrl_BreakView, in document: 004.idw
     The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

Below is my double split code:

Option Explicit On

Sub Main()

    ActiveSheet = ThisDrawing.Sheet("Sheet:1")
    Dim viewL = ActiveSheet.View("VIEW1")
    Dim viewDir As Integer = 0 ' Set this to 0 for a view that is wide in the horizontal direction,
                               ' Set it to 1 if the view is high in the vertical direction.
    Dim view = viewL.View
    
    'Delete break view if applied
    If (view.BreakOperations.Count > 0) Then
        view.BreakOperations(1).Delete
    End If
    
    'Set midpoint of view
    Dim cMid As Double = view.Center.X
'''    If (viewDir = 1) Then cMid = view.Center.Y
    
    'Get model length
    Dim modelSize As Double = GetExtents(viewL.ModelDocument, 0) ' 0 for the X extents of the model, 1 for Y, 2 for Z
    If (modelSize < 5000) Then Return
    Dim pitchAndSome As Double = Parameter("00001.iam.dim_Offset_BagHole_Edge") + 100

    If Parameter("00001.iam.dim_Casing_Split_Length_Active") = 0 Then
    'Single break view
        Dim breakWidth As Double = (modelSize - 4500) * 0.1 * view.Scale ' * 0.1 = mm; * 2.54 = inch
        If (viewDir = 0) Then
            Dim startPt = ThisApplication.TransientGeometry.CreatePoint2d(cMid - breakWidth/2, 0)
            Dim endPt = ThisApplication.TransientGeometry.CreatePoint2d(cMid + breakWidth/2, 0)
            view.BreakOperations.Add(BreakOrientationEnum.kHorizontalBreakOrientation, startPt, endPt, _
                            BreakStyleEnum.kStructuralBreakStyle, 10, 0.3)
        Else
'''            Dim startPt = ThisApplication.TransientGeometry.CreatePoint2d(0, cMid - breakWidth/2)
'''            Dim endPt = ThisApplication.TransientGeometry.CreatePoint2d(0, cMid + breakWidth/2)
'''            view.BreakOperations.Add(BreakOrientationEnum.kHorizontalBreakOrientation, startPt, endPt, _
'''                            BreakStyleEnum.kStructuralBreakStyle, 10, 0.3)
        End If
        
    ElseIf Parameter("00001.iam.dim_Casing_Split_Length_Active") = 1 Then
    'Double break view
'''        Dim breakWidth_preSplit As Double = (modelSize - 2500) * 0.1 * view.Scale ' * 0.1 = mm; * 2.54 = inch
'''        Dim breakWidth_postSplit As Double = (modelSize - 1500) * 0.1 * view.Scale ' * 0.1 = mm; * 2.54 = inch

        If (viewDir = 0) Then
        'Pre Split
            Dim startPt_preSplit = ThisApplication.TransientGeometry.CreatePoint2d((pitchAndSome)* 0.1 * view.Scale, 0)
            Dim endPt_preSplit = ThisApplication.TransientGeometry.CreatePoint2d((Parameter("004.ipt.d246") - pitchAndSome)* 0.1 * view.Scale, 0)
            view.BreakOperations.Add(BreakOrientationEnum.kHorizontalBreakOrientation, startPt_preSplit, endPt_preSplit, _
                    BreakStyleEnum.kStructuralBreakStyle, 10, 0.3)
        'Post Split
            Dim startPt_postSplit = ThisApplication.TransientGeometry.CreatePoint2d((Parameter("004.ipt.d246") + pitchAndSome)* 0.1 * view.Scale, 0)
            Dim endPt_postSplit = ThisApplication.TransientGeometry.CreatePoint2d((Parameter("004.ipt.d246") + Parameter("004.ipt.d245") - pitchAndSome)* 0.1 * view.Scale, 0)
            view.BreakOperations.Add(BreakOrientationEnum.kHorizontalBreakOrientation, startPt_postSplit, endPt_postSplit, _
                    BreakStyleEnum.kStructuralBreakStyle, 10, 0.3)
        Else
'''            Dim startPt = ThisApplication.TransientGeometry.CreatePoint2d(0, cMid - breakWidth/2)
'''            Dim endPt = ThisApplication.TransientGeometry.CreatePoint2d(0, cMid + breakWidth/2)
'''            view.BreakOperations.Add(BreakOrientationEnum.kVerticalBreakOrientation, startPt, endPt, _
'''                    BreakStyleEnum.kStructuralBreakStyle, 10, 0.3)
        End If

    End If End Sub Function GetExtents(doc As Document, direction As Integer) As Double Dim def As Inventor.ComponentDefinition = DocGetComponentDefinition(doc) If (def Is Nothing) Then Return 0.0 Dim extentsBox As Inventor.Box = def.RangeBox Dim ptMin As Inventor.Point = extentsBox.MinPoint Dim ptMax As Inventor.Point = extentsBox.MaxPoint Dim dLength As Double = ptMax.X - ptMin.X Dim dWidth As Double = ptMax.Y - ptMin.Y Dim dHeight As Double = ptMax.Z - ptMin.Z Dim currentExtents(2) As Double currentExtents(0) = doc.UnitsOfMeasure.ConvertUnits(dLength, Inventor.UnitsTypeEnum.kDatabaseLengthUnits, _ doc.UnitsOfMeasure.LengthUnits()) currentExtents(1) = doc.UnitsOfMeasure.ConvertUnits(dWidth, Inventor.UnitsTypeEnum.kDatabaseLengthUnits, _ doc.UnitsOfMeasure.LengthUnits()) currentExtents(2) = doc.UnitsOfMeasure.ConvertUnits(dHeight, Inventor.UnitsTypeEnum.kDatabaseLengthUnits, _ doc.UnitsOfMeasure.LengthUnits()) Return currentExtents(direction) End Function Function DocGetComponentDefinition(ByVal doc As Inventor.Document) As Inventor.ComponentDefinition If (doc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject) Then Dim partDoc As Inventor.PartDocument = CType(doc, Inventor.PartDocument) Return CType(partDoc.ComponentDefinition, Inventor.ComponentDefinition) ElseIf (doc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject) Then Dim assemDoc As Inventor.AssemblyDocument = CType(doc, Inventor.AssemblyDocument) Return CType(assemDoc.ComponentDefinition, Inventor.ComponentDefinition) End If Return Nothing End Function

 It adds the first break in the double split section but not the second and then I get the above error

 

Any advice please?

 

 

3 REPLIES 3
Message 2 of 4

Bump up
Message 3 of 4

Please any advice

Message 4 of 4

 

I mannaged to make a double break using this code if anyone is still interested.

 

SyntaxEditor Code Snippet

If (ActiveSheet.Name <> "Sheet:1") Then Return
Dim viewL = ActiveSheet.View("VIEW5")
Dim view = viewL.View
If (view.BreakOperations.Count > 0) Then
    Try 
        view.BreakOperations(1).Delete    
    Catch 
        'Der var ingen at slette
    End Try
    
    Try 
        view.BreakOperations(1).Delete    
    Catch 
        'Der var ingen at slette
    End Try
    
End If

If view.Width <= 22 Then Return 'View Width in cm

'Set midpoint of view
Dim cMid As Double = view.Center.X

'Dim breakWidth As Double = view.Width - 20 'Break Value in cm 
Dim breakWidth_PreSplit As Double = view.Width - 20

Dim  startPt_preSplit = ThisApplication.TransientGeometry.CreatePoint2d(((cMid - (breakWidth_PreSplit/2.7))), 0)
Dim  endPt_preSplit = ThisApplication.TransientGeometry.CreatePoint2d(((cMid - (breakWidth_PreSplit/1.1))), 0)
view.BreakOperations.Add(BreakOrientationEnum.kHorizontalBreakOrientation, startPt_preSplit, endPt_preSplit)


'Set midpoint of view
Dim ocMid As Double = view.Center.X

Dim breakWidth_postSplit As Double = view.Width - 20 'Break Value in cm 

Dim startPt_postSplit = ThisApplication.TransientGeometry.CreatePoint2d(((ocMid + (breakWidth_postSplit/0.75))),0)
Dim endtPt_postSplit = ThisApplication.TransientGeometry.CreatePoint2d(((ocMid + (breakWidth_postSplit/5))),0)
view.BreakOperations.Add(BreakOrientationEnum.kHorizontalBreakOrientation, startPt_postSplit , endtPt_postSplit)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report