Get Access to Face with API after MoveFeature

Get Access to Face with API after MoveFeature

florian_wenzel
Advocate Advocate
313 Views
3 Replies
Message 1 of 4

Get Access to Face with API after MoveFeature

florian_wenzel
Advocate
Advocate

Hi,

 

Inventor 2022

API VB.NET VisualStudio

 

I try to get Access to Face with API, but after a Feature "MoveFeature".

I got Error.

I am in Part Envireoment, should i also use a FaceProxy, but i dont understand this.

florian_wenzel_0-1664357784223.png

florian_wenzel_1-1664357813278.png

florian_wenzel_2-1664357896869.png

When i Select the Extrusion, then it show me the Origin Position.

What is it now a FaceProxy?

 

How to use the Face after MoveFeature.

 

This is my Code:

 

 

 

 

 

Imports System.Runtime.InteropServices
Imports Inventor
Imports Microsoft.Win32
Imports System.Collections.Generic
Imports System.Linq
Imports System.IO

Module CommandFunctionButton_10

    Public Sub CommandFunctionfweButton_10()

        Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
        Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
        Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
        Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry

        Dim oSurfaceBody As SurfaceBody = oCompDef.SurfaceBodies.Item(1)
        Dim oFaceOrigin As Face = oSurfaceBody.Faces.Item(1)
        Dim oVertex As Vertex = oFaceOrigin.Vertices.Item(1)
        Dim oVertexPoint As Point = oVertex.Point
        Dim oCenterPoint As WorkPoint = oCompDef.WorkPoints.Item(1)
        Dim oCenterPointOrigin As Point = oCenterPoint.Point
        Dim oDistanceFromOrigin As Double = oVertexPoint.DistanceTo(oCenterPointOrigin)
        Dim oWorkAxis As WorkAxis = oCompDef.WorkAxes.AddByTwoPoints(oVertex, oCenterPoint)


        Dim oObjColl As ObjectCollection = oTO.CreateObjectCollection
        oObjColl.Add(oSurfaceBody)

        Dim oMoveDef As MoveDefinition = oCompDef.Features.MoveFeatures.CreateMoveDefinition(oObjColl)
        Dim oMoveAlongAxis As MoveAlongRayMoveOperation = oMoveDef.AddMoveAlongRay(oWorkAxis, True, oDistanceFromOrigin)
        Dim oMoveFeature As MoveFeature = oCompDef.Features.MoveFeatures.Add(oMoveDef)


        Dim oFace As Face = oSurfaceBody.Faces.Item(2)


    End Sub
End Module

 

 

 

 

 

 

 

Error: Unknow Error

florian_wenzel_0-1664358217789.png

 

Thanks for Any Suggestion

 

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

florian_wenzel
Advocate
Advocate

What means those Function?

 

Inventor 2022 Help | MoveFeature.Faces Property | Autodesk

MoveFeature.Faces() As Faces

Description
Property that returns a collection that provides access to all of the faces of the feature. The Faces collection object will return the faces that still currently exist in the part. For example, if a face has been consumed by additional modeling operations it will not be returned.

 

Can i Use the Faces, when i Write:

 

Dim oFaces As Faces = oMoveFeature.Faces
Dim oFaceNew As Face = oFaces.Item(1)

 

 

Than i Become Error

 

 

Inventor 2022 Help | MoveFeature.Transformation Property | Autodesk

MoveFeature.Transformation() As Matrix

Description
A transformation matrix that moves an extrude, revolve, or sweep feature to a new location.

 

 

Can in Part Enviroment with Matrix make a Transformation of the Body?

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @florian_wenzel.  The information on the online help page for that Transformation property of the MoveFeature object is confusing/misleading.  It says that property is ReadOnly, but the description says it is for moving features within a part to a new location.  So I would say that you still have to use the other related methods to move/rotate the SurfaceBody object, instead of a Matrix.

I assume that you are having a hard time working with variables that represent bodies and faces that were defined before the move feature was created, because I believe that move feature essentially re-creates/re-defines them.  Sort of like when you have a face, then create a feature on that face, which results in multiple new faces interrupting the original face, then the reference to the original face ceases to exist do to the changes.  This may be the case when using MoveFeatures.  Just a theory that would need to be tested to see if its true.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 4

florian_wenzel
Advocate
Advocate

Hi @WCrihfield 

 

i try to do this in other way now.

I Open a File A, copy the SurfaceBody, and then i Create a New partDocument_B.

To this NewPartDocuemnt_B i past the  body from Part_A.

 

0 Likes