Project Center Point into Drawing Sketch

Project Center Point into Drawing Sketch

Anonymous
Not applicable
893 Views
1 Reply
Message 1 of 2

Project Center Point into Drawing Sketch

Anonymous
Not applicable

I thought this would be simple, projecting a centerpoint from a view's underlying reference document's assembly origin into a sketch created on the view.

I keep getting invalid parameter error.  Since the object is of the first layer, I shouldn't need (nor can i create) a proxy version of it.  Does anybody know how to fix this?

'excerpt inline of main routine
Dim wporigin As WorkPoint = SetWorkPointVisibility(vSide, "Center Point", True)
Dim skSection As DrawingSketch = vSide.Sketches.Add()
 Dim pOrigin As SketchPoint = skSection.AddByProjectingEntity(wporigin)

'called helper routines
 Public Function SetWorkPointVisibility(ByRef v As DrawingView, ByRef wpName As String, ByVal visibility As Boolean) As WorkPoint
        Dim doc As Inventor.Document = v.ReferencedDocumentDescriptor.ReferencedDocument
        Dim cd As ComponentDefinition = Nothing
        If doc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
            cd = CType(doc, AssemblyDocument).ComponentDefinition
        ElseIf doc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
            cd = CType(doc, PartDocument).ComponentDefinition
        End If
        Dim wp As WorkPoint = FindWorkPoint(cd, wpName)
        If wp IsNot Nothing Then
            v.SetVisibility(wp, True)
            Return wp
        End If
        Return Nothing
    End Function

    Public Function FindWorkPoint(ByRef cd As ComponentDefinition, ByVal wpName As String) As WorkPoint
        Dim wps As WorkPoints = Nothing
        If cd.Type = ObjectTypeEnum.kAssemblyComponentDefinitionObject Then
            Dim acd As AssemblyComponentDefinition = cd
            wps = acd.WorkPoints
        ElseIf cd.Type = ObjectTypeEnum.kPartComponentDefinitionObject Then
            Dim pcd As PartComponentDefinition = cd
            wps = pcd.WorkPoints
        End If
        If wps IsNot Nothing Then
            For Each wp As WorkPoint In wps
                If wp.Name = wpName Then Return wp
            Next
        End If
        Return Nothing
    End Function
0 Likes
Accepted solutions (1)
894 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Thanks to Jon.Balgley for working hard on Inventor Answer day and today to find the solution a different process for the api than expected.  It is posted in that thread:

http://forums.autodesk.com/t5/inventor-answer-day/drawing-sketch-project-geometry-using-api/m-p/6012...