Create Detail view with API

Create Detail view with API

lmc.engineering
Advocate Advocate
750 Views
2 Replies
Message 1 of 3

Create Detail view with API

lmc.engineering
Advocate
Advocate

Hi All

 

I'm trying to create a Circular fenced detail drawing view using iLogic, but seem to be running in to an issue. I've used the Programming help and googled to death but can't seem to get anywhere.

 

With the following Code, I essentially get an error message saying "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"

 

at this point it fails:

 

"at Inventor.DrawingViews.AddDetailView(DrawingView ParentView, Point2d Position, DrawingViewStyleEnum ViewStyle, Boolean CircularFence, Point2d FenceCenterOrCornerOne, Object FenceRadiusOrCornerTwo, Object AttachPoint, Object Scale, Boolean ShowLabel, String Name, Boolean Reserved)"

 

Problem is I don't know which parameter is incorrect. I've spent a fair few hours trying to solve this and now I'm hoping someone here may be able to enlighten me as to the issue?

 

SyntaxEditor Code Snippet

Sub CreateView()
    ' Set a reference to the drawing document.
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
	
    'References this drawing sheet
    Dim oSheet As Inventor.Sheet
    oSheet = oDrawDoc.ActiveSheet

    ' Select a drawing view.
    Dim oDrawingView As DrawingView
    oDrawingView = ActiveSheet.View("A").View
	
    ' Ready code for creating of reference points
    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry

    ' Set a reference to the center of the base view.
    Dim oPoint As Point2d
    oPoint = oDrawingView.Center
    oPoint.X = oPoint.X + oDrawingView.Width
	
    Dim oCenterPoint As Point2d
    oCenterPoint = oTG.CreatePoint2d(oDrawingView.Center.X, oDrawingView.Center.Y)

    ' Create the detail view.
    Dim oDetailView As DetailDrawingView
    oDetailView = oSheet.DrawingViews.AddDetailView(oDrawingView, oPoint, kFromBaseDrawingViewStyle, True, oCentrePoint, 1, , oDrawingView.Scale*3, True, "Detail C")
End Sub

Thanks

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

dgreatice
Collaborator
Collaborator

Hi,

 

 

Sub CreateView()
    ' Set a reference to the drawing document.
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
	
    'References this drawing sheet
    Dim oSheet As Inventor.Sheet
    oSheet = oDrawDoc.ActiveSheet

    ' Select a drawing view.
    Dim oDrawingView As DrawingView
    oDrawingView = ActiveSheet.View("A").View
	
    ' Ready code for creating of reference points
    Dim oTG As TransientGeometry
    oTG = ThisApplication.TransientGeometry

    ' Set a reference to the center of the base view.
    Dim oPoint As Point2d
    oPoint = oDrawingView.Center
    oPoint.X = oPoint.X + oDrawingView.Width

Dim oCurveSeg as DrawingCurveSegment
oCurveSeg = Thisapplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick")
Dim oCenterPoint As Point2d oCenterPoint = oCurveSeg.StartPoint
' Create the detail view. Dim oDetailView As DetailDrawingView oDetailView = oSheet.DrawingViews.AddDetailView(oDrawingView, oPoint, kFromBaseDrawingViewStyle, True, oCentrePoint, 1, , oDrawingView.Scale*3, True, "Detail C") End Sub
Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 3 of 3

lmc.engineering
Advocate
Advocate

Thanks for the reply,

 

So essentially my centrepoint assignment was wrong.

 

Unfortunately I can't use the pick selection option as I need to place the view automatically, but at least I know what I need to work on now.

 

Thanks again

0 Likes