How to get all entities in a part / assembly

How to get all entities in a part / assembly

Anonymous
Not applicable
877 Views
1 Reply
Message 1 of 2

How to get all entities in a part / assembly

Anonymous
Not applicable

I want to collect all the objects/features in a part or assembly and would like to generate a report of all entities.

In part I would like to report all features, its type, the geometrical information of the feature, the sketch associated to the features and the sketch dimensions

In assembly I would like to get all the components its name, the part name (.ipt or .iam), the location and orientation of the component w.r.t to the global Coordinate system.

How to get the above information using VB .NET Inventor program?

Thanks

Regards

PV Subramanian

 

0 Likes
878 Views
1 Reply
Reply (1)
Message 2 of 2

xiaodong_liang
Autodesk Support
Autodesk Support

Hi PV Subramanian,

 

All the information you need are stored with the properties of corresponding API objects. You just need to iterate the components of the assembly to get properties of  component. In each component, iterate its native document (say part), iterate features collection and get properties. The code snippet is  a kind of skeleton for your reference. 

 

However, if you not familiar with objects, assembly structure, part structure,  I strongly recommend you take a look at the training labs, either video, or PPT:

 

https://github.com/ADN-DevTech/Inventor-Training-Material

http://adndevblog.typepad.com/manufacturing/2013/05/api-webcast-archive.html

 

 

       Dim oTopAssembly As AssemblyDocument = m_inventorApp.ActiveDocument
        Dim oEachComp As ComponentOccurrence

        For Each oEachComp In oTopAssembly.ComponentDefinition.Occurrences


            'transformation of component w.r.t to the global coordinate system (in context of top assembly)
            Dim oTrans As Matrix = oEachComp.Transformation

            'for other properties of component, please check API help. e.g. component name
            Dim oCompName As String = oEachComp.Name

            '*************

            'native document of this component
            Dim oNativeDoc As Document = oEachComp.Definition.Documen

            'to check part document
            If oNativeDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
                Dim oNativeDocDef As PartComponentDefinition = oNativeDoc.ComponentDefinition

                Dim oEachFeature As PartFeature
                For Each oEachFeature In oNativeDocDef.Features

                    Dim oExtrudeF As ExtrudeFeature = oEachFeature
                    'check feature's type. e.g. whether it is an extrude feature
                    If oEachFeature.Type = ObjectTypeEnum.kExtrudeFeatureObject Then

                    End If

                    'get faces collection of the feature
                    Dim oFaces As Faces = oEachFeature.Faces
                    Dim oEachF As Face
                    For Each oEachF In oFaces
                        ' iterate each face. get properties of face. or edges of the face...
                        'please check API help. 
                    Next

                    'get definition of the feature
                    Dim oExtrudeDef As ExtrudeDefinition = oExtrudeF.Definition

                    'get sketch with the feature
                    Dim oSketch As PlanarSketch = oExtrudeDef.Profile.Parent

                    'dump information of sketch
                    Dim oGeoCons As GeometricConstraint
                    For Each oGeoCons In oSketch.GeometricConstraints
                        'each geometric constraint
                    Next

                    Dim oDimCons As DimensionConstraint
                    For Each oDimCons In oSketch.DimensionConstraints
                        'each dimension constraint
                    Next

                Next
            End If

        Next

 

0 Likes