Use iLogic to change Reference Data options in drawing views

Use iLogic to change Reference Data options in drawing views

Anonymous
Not applicable
1,449 Views
10 Replies
Message 1 of 11

Use iLogic to change Reference Data options in drawing views

Anonymous
Not applicable

I am truing to write a quick iLogic rule to cycle through all sheets of a drawing and change the reference data options to the following:

 

Line Style: As Parts

Hidden Line Calculation: All Bodies

Margin: 100

 

(see attached image)

 

I have the basic for each loops to go through each sheet and each drawing view but I'm not sure on the code required to change these values. There doesn't appear to be a reference anywhere of the commands available.

 

Many thanks

0 Likes
1,450 Views
10 Replies
Replies (10)
Message 2 of 11

frederic.vandenplas
Collaborator
Collaborator

Hi,

 

I also did not found anything under the drawingview object, so probably the api is not exposed. 

Only Autodesk can confirm this i.

@Anonymous is there a list available of things that are not exposed, this would help us save lot of time 🙂

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 3 of 11

Anonymous
Not applicable

Thanks for your reply.

 

If we can get Autodesk to confirm or deny it can be edited in iLogic that would be great.

I found this post earlier which details the iLogic required for turning off "Definition in Base View". However I can't find the command that was called up in this iLogic anywhere so I'm hoping there are other hidden commands for what I require.

 

 

Thanks

0 Likes
Message 4 of 11

Josh_Hunt
Advocate
Advocate

Did anyone solve this?

I'm looking for the exact same API objects. I'm using Inventor 2017.

 

image.png

 

 

Josh Hunt
0 Likes
Message 5 of 11

maxim.teleguz
Advocate
Advocate

I am currently looking for the same thing. 2020

0 Likes
Message 6 of 11

c_hoppen
Advocate
Advocate

Me too. Dez. 17 2024. poor...!

0 Likes
Message 7 of 11

maxim.teleguz
Advocate
Advocate

use this code in the meantime to calculate the suggested margin view size:

Sub Main()
    ' Check if the active document is a drawing
    Dim DrawingDoc As Inventor.DrawingDocument = ThisDrawing.Document
    If DrawingDoc.DocumentType <> kDrawingDocumentObject Then
        MessageBox.Show("Active document must be a drawing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    ' Prompt the user to select a specific view
    Dim oApp As Inventor.Application = ThisApplication
    Dim SelectedView As Inventor.DrawingView = oApp.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View")

    ' Check if a view was selected
    If IsNothing(SelectedView) Then
        MessageBox.Show("No view was selected. Exiting.", "Selection Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Exit Sub
    End If

    ' Retrieve the margin value for the selected view
    Dim MarginValue As Double = GetViewMargin(SelectedView)
    
    ' Display or use the margin value as needed
    MessageBox.Show("Margin value for selected view: " & MarginValue, "Margin Value", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

Private Function GetViewMargin(DwgView As Inventor.DrawingView) As Double
    ' Get the size of the drawing view
    Dim viewWidth As Double = DwgView.Width
    Dim viewHeight As Double = DwgView.Height
    Dim marginX As Double = viewWidth
    Dim marginY As Double = viewHeight
    ' Return the calculated margin value
    Return marginX ' Assuming uniform margin, you can return marginX or marginY
End Function
0 Likes
Message 8 of 11

c_hoppen
Advocate
Advocate

My comment related to the original question. We can't access the DrawingView.ReferenceDataDisplayStyle property via the API. It is not even documented.

It works with VBA: 

Sub HideReferenceLines(ByVal drawingView As drawingView)
    drawingView.ReferenceDataDisplayStyle = kDisplayStyleOff
End Sub
Message 9 of 11

maxim.teleguz
Advocate
Advocate

finally! 

have code that will adjust the margin

Sub Main()

    Dim oApp As Inventor.Application = ThisApplication

    ' Ensure a drawing document is active
    Dim oDrawingDoc As Inventor.DrawingDocument = Nothing
    If oApp.ActiveDocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
        oDrawingDoc = oApp.ActiveDocument
    Else
        MessageBox.Show("Please open a drawing document first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    ' Prompt the user to select a specific view
    Dim SelectedView As Inventor.DrawingView = Nothing
    Try
        SelectedView = oApp.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a Detail or Section View")
    Catch ex As Exception
        MessageBox.Show("Error selecting view: " & ex.Message, "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End Try

    ' Check if a view was selected
    If SelectedView Is Nothing Then
        MessageBox.Show("No view was selected. Exiting.", "Selection Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Exit Sub
    End If

    ' Calculate a margin from the selected view using your logic
    Dim CalculatedMargin As Double = GetViewMargin(SelectedView)

    ' If it’s a DetailDrawingView
    If TypeOf SelectedView Is DetailDrawingView Then
        Dim oDetailView As DetailDrawingView = CType(SelectedView, DetailDrawingView)
        Dim currentMargin As Double = oDetailView.Margin
        MessageBox.Show("Current Detail View Margin: " & currentMargin & vbCrLf & _
                        "Calculated Margin: " & CalculatedMargin, "Margin", MessageBoxButtons.OK, MessageBoxIcon.Information)

        ' Set the margin from the calculated value
        oDetailView.Margin = CalculatedMargin
        oDrawingDoc.Update()
        MessageBox.Show("Detail View Margin updated to " & CalculatedMargin, "Margin Updated", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Exit Sub
    End If

    ' If it’s a SectionDrawingView
    If TypeOf SelectedView Is SectionDrawingView Then
        Dim oSectionView As SectionDrawingView = CType(SelectedView, SectionDrawingView)
        Dim currentMargin As Double = oSectionView.Margin
        MessageBox.Show("Current Section View Margin: " & currentMargin & vbCrLf & _
                        "Calculated Margin: " & CalculatedMargin, "Margin", MessageBoxButtons.OK, MessageBoxIcon.Information)

        ' Set the margin from the calculated value
        oSectionView.Margin = CalculatedMargin
        oDrawingDoc.Update()
        MessageBox.Show("Section View Margin updated to " & CalculatedMargin, "Margin Updated", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Exit Sub
    End If

    ' If it’s neither detail nor section
    MessageBox.Show("Selected view is not a Detail or Section view. No margin property available.", "Not Applicable", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub

Private Function GetViewMargin(DwgView As Inventor.DrawingView) As Double
    ' Example calculation:
    ' Currently, this just returns the width of the view as the margin.
    ' Adjust this logic to whatever makes sense for your scenario.
    
    Dim viewWidth As Double = DwgView.Width
    Dim viewHeight As Double = DwgView.Height
    ' For now, just return viewWidth. You can implement a more complex calculation if needed.
    Return viewWidth
End Function




0 Likes
Message 10 of 11

donaldleigh
Advocate
Advocate

here is the code for the Hidden Line Calculation: All Bodies

 

DrawingView.HiddenLineCalculationForAllBodies() As Boolean

0 Likes
Message 11 of 11

Stakin
Collaborator
Collaborator

maybe 

DrawingView.SetDesignViewRepresentation Method

Parent Object: DrawingView

Description

Method that sets a design view representation for a drawing view of an assembly. This method fails for drawing views of parts and presentations and in the case where the model (assembly) is unresolved.

Syntax

DrawingView.SetDesignViewRepresentation( Representation As String, [Associative] As Boolean )

0 Likes