VB.net - Temperamental Projected View

VB.net - Temperamental Projected View

matt.daviesWN4HT
Participant Participant
317 Views
3 Replies
Message 1 of 4

VB.net - Temperamental Projected View

matt.daviesWN4HT
Participant
Participant

Hi all

 

I am currently trying to avoid scratching a bald spot into my head trying to figure out why my code is being temperamental.

 

I have placed the projected view code into it's own function which works when I am using an Assembly but then throws an error when I am using a Part. I think I have managed to hard code as many of the inputs as I can all with the same results for testing purposes, with the error being "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"

 

    Public Shared Function AddProjectionToDrawing(ByVal oSheet As Sheet, ByVal oParentView As DrawingView, Optional ViewInfo As Collection = Nothing, Optional oCentrePoint As Inventor.Point2d = Nothing) As DrawingView

        If IsNothing(ViewInfo) And IsNothing(oCentrePoint) Then Exit Function
        Dim oProjectedView As DrawingView

        If IsNothing(ViewInfo) Then
            oProjectedView = oSheet.DrawingViews.AddProjectedView(oParentView, g_inventorApplication.TransientGeometry.CreatePoint2d(oCentrePoint.X, oCentrePoint.Y), DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
        Else
            oProjectedView = oSheet.DrawingViews.AddProjectedView(oParentView, g_inventorApplication.TransientGeometry.CreatePoint2d(ViewInfo.Item(7), ViewInfo.Item(8)), DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
        End If

        If Not IsNothing(oProjectedView) Then AddProjectionToDrawing = oProjectedView

    End Function

 

Would the issue be in the base view/my code/known bug?

0 Likes
Accepted solutions (1)
318 Views
3 Replies
Replies (3)
Message 2 of 4

matt.daviesWN4HT
Participant
Participant

Scratch this. 

 

Definitely my code. I had the projected view slightly off to the center horizontally of the base that was the issue rather than the vertically that I was expecting

0 Likes
Message 3 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

I was in the process of figuring out what is the problem. could not find it. I see that you did that yourself. But i did refactor your code a bit. maybe it is some help to you.

Public Shared Function AddProjectionToDrawing(ByVal oSheet As Sheet, ByVal oParentView As DrawingView, oCentrePoint As Inventor.Point2d) As DrawingView

    If IsNothing(oCentrePoint) Then Return Nothing
    Return oSheet.DrawingViews.AddProjectedView(oParentView, oCentrePoint, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)

End Function

Public Shared Function AddProjectionToDrawing(ByVal oSheet As Sheet, ByVal oParentView As DrawingView, ViewInfo As Collection) As DrawingView

    If IsNothing(ViewInfo) Then Return Nothing
    If TypeOf ViewInfo.Item(7) IsNot Double Then Throw New ArgumentException("ViewInfo.Item(7) isnot a double")
    If TypeOf ViewInfo.Item(8) IsNot Double Then Throw New ArgumentException("ViewInfo.Item(8) isnot a double")

    Dim point As Point2d = g_inventorApplication.TransientGeometry.CreatePoint2d(ViewInfo.Item(7), ViewInfo.Item(8))
    Return AddProjectionToDrawing(oSheet, oParentView, point)

End Function

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 4 of 4

matt.daviesWN4HT
Participant
Participant

The solution to the issue was the Center Point for the Projected View was not far enough from the Center Point of the Base View. If this was done manually it wouldn't generate the sample view at the distance that I was using

0 Likes