Inventor API how to locate an edge and/or face

Inventor API how to locate an edge and/or face

Anonymous
Not applicable
4,713 Views
2 Replies
Message 1 of 3

Inventor API how to locate an edge and/or face

Anonymous
Not applicable

I am new to Inventor and the API.  I have been successful in creating sketches and extrusions.  Now I want to locate edges to place chamfers and fillets on.  I can't seem to find the right method(s) for this.  I would appreciate it if someone would direct me toward some methods to try. 

0 Likes
4,714 Views
2 Replies
Replies (2)
Message 2 of 3

wayne.brill
Collaborator
Collaborator

Hi,

 

There is this post which has some labs. Lab 5 should help. It has an example of using FindUsingRay() which I believe will meet your requirement.

http://modthemachine.typepad.com/my_weblog/2012/02/inventor-api-labs-step-by-step.html

 

(search this forum on FindUsingRay - there are several posts)

 

Also see this topic in the API help: "Understanding Solids - Working with the B-Rep"

 

In some cases it makes sense to add an attribute to the edge. Using this approach you can easily get the edge. See this topic in the API help: "Custom Data->Working with attributes".

 

Thanks,

Wayne

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

Jef_E
Collaborator
Collaborator

To find all edges and surfaces you should look in the partcomponentdefinition.surfacebodies.item()

 

SurfaceBody Object

SurfaceBody Object

Description

The SurfaceBody object. See the article in the overviews section.

Methods

Name Description
BindTransientKeyToObject Bind the transient key of a subentity on this body to a live object.
CalculateFacets Obtain the facetted representation for the given chord-height tolerance. If stored facets available for this tolerance, then those are returned.
CalculateFacetsAndTextureMap Obtain the facetted representation for the given chord-height tolerance. If stored facets available for this tolerance, then those are returned.
CalculateStrokes Obtain the stroked or polygonal representation for the given chord-height tolerance. Client to deallocate pointers with CoTaskMemFree.
ClearAppearanceOverrides Method that clears all the appearance overrides that have been applied to faces or features in the body. When the SurfaceBody has its IsSolid return True, this method sets the AppearanceSourceType to kBodyAppearance for all the features and kFeatureAppearance for all the faces in the body. When the SurfaceBody has its IsSolid return False, this method sets the AppearanceSourceType to kBodyAppearance for all the features directly owned by the work surface and kFeatureAppearance for all the faces in the body.
Delete Method that deletes this SurfaceBody object.
FindUsingRay Please note: As of Autodesk Inventor 5.3 Service Pack 2, the FindUsingRay method below has superseded LocateUsingRay. Please update your applications accordingly. Method that fires a ray through the part or assembly and returns the entities intersected by the ray. The objects intersected by the ray are returned in the order in which they are intersected, with the first entities returned being those closest to the clipping plane. There is also a precedence in the type of entities returned. The entities returned can be Vertex, Edge, or Face objects. The precedence is in that order. If the ray intersects a vertex, then that vertex is returned and none of the edges or faces that connect to that vertex are returned. If the ray intersects an edge, then that edge is returned and none of the faces that connect to the edge are returned. If the ray intersects a face, then that face is returned. If desired, you can use the functionality provided by the B-Rep portion of the API to obtain the various associated objects from the entity returned. For example if you need a face but an edge is returned, you can use the Faces property of the Edge object to get the associated faces. The start point defines the physical starting point from which to determine intersections. Any intersections behind the start point are ignored. However, the ray is infinite from the start point, so all intersections in the direction of the ray will be returned.
GetAppearanceTextureMappingData Gets the texture mapping type and alignment.
GetExistingFacets Obtain the faceted representation for the given chord-height tolerance as. Fails if the tolerance supplied is not pre-existing/
GetExistingFacetsAndTextureMap Method that returns the specified set of existing display facets. Existing display facets are stored to single-precision floating point accuracy. This is typically adequate accuracy for display purposes. If a more accurate result is required you can use the CalculateFacets method which will calculate new facets to a given tolerance at double-precision accuracy.
GetExistingFacetTolerances Method that gets the tolerances that were used to calculate the existing sets of display facets. These can be used to determine if any existing facets have been calculated within your desired accuracy. The tolerance value is also used as an index to specify which set of existing facets to retrieve when using the GetExistingFacets method.
GetExistingStrokes Method that returns the specified set of strokes from the SurfaceBody, Face or Edge the method was called from. Existing strokes are stored to single-precision floating point accuracy. This is typically adequate accuracy for display purposes. If a more accurate result is required you can use the CalculateStrokes method, which will calculate new strokes to a given tolerance at double-precision accuracy. If you are using this method within Apprentice, you can use the DisplayAffinity property to optimize Apprentice for access to strokes. Setting this property to True before you begin to traverse an assembly notifies Apprentice not to load any B-rep entities.
GetExistingStrokeTolerances Method that gets the tolerances that were used to calculate the existing sets of display strokes. These can be used to determine if any existing strokes have been calculated within your desired accuracy. The tolerance value is also used as an index to specify which set of existing strokes to retrieve when using the GetExistingStrokes method. If you are using this method within Apprentice, you can use the DisplayAffinity property to optimize Apprentice for access to strokes. Setting this property to True before you begin to traverse an assembly notifies Apprentice not to load any B-rep entities.
GetReferenceKey Method that generates and returns the reference key for this entity.
GetRenderStyle Method that gets the render style currently used for this body.
IsEntityValid Method that returns whether an entity passes the quality check at the specified level.
LocateUsingPoint Finds the object of specified type within the proximity of the given point. By default an internal tolerance is used to gauge the proximity.
SetAppearanceTextureMappingData Method that sets the texture mapping type and alignment. Setting this value is only valid when the appearance assigned to the body has a texture defined.
SetRenderStyle Method that sets the render style to use for this body.

Properties

Name Description
AffectedByFeatures Property that returns the features that affected this body. The returned enumerator includes the feature that created this body. This property returns Nothing for transient bodies
AlternateBody Property that returns a new SurfaceBody that was derived from the existing body using the specified form input. The primary purpose of this property is to obtain a body that consists entirely of NURBS surfaces.
Appearance Read-write property that gets and sets the current appearance of the body. The appearance asset being used when setting this property must be from the current document’s AppearanceAssets collection, otherwise an error will occur. Setting this property with an asset will result in setting the AppearanceSourceType to kOverrideAppearance. Setting this property to Nothing removes the override and results in setting the AppearacneSourceType to kPartAppearance so that the body will display using the appearance associated with the owning part for solid features or the appearance defined by application for surface features.
AppearanceSourceType Read-write property that gets and sets the source of the appearance for the body. Setting this property to kPartAppearance will remove the override.
Application Returns the top-level parent application object. When used the context of Inventor, an Application object is returned. When used in the context of Apprentice, an ApprenticeServer object is returned.
AttributeSets Property that returns the AttributeSets collection object associated with this object.
ComponentDefinition Gets the primary that resides in this file.
ConcaveEdges Property that returns an that contains all of the concave edges of the surface body. The CollectionType of the output EdgeCollection is set to kAllConcave.
ConvexEdges Property that returns an that contains all of the convex edges of the surface body. The CollectionType of the output EdgeCollection is set to kAllConvex.
CreatedByFeature Property that returns the feature that resulted in the creation of this body. This property returns Nothing for transient bodies.
DataIO Returns the DataIO object.
Edges Gets the referenced by this SurfaceBody.
Exported Property that gets and sets whether the object is exported. Objects must be marked for export in order for them to be derived.
Faces Property that returns a collection object generated as a result of the feature.
FaceShells Property that returns the collection object.
GeometryForm Gets the form of the underlying geometry as a combination of one or more CurveGeometryFormEnum values.
IsPointInside Property that returns a constant indicating whether the specified point is inside, on or outside the body.
IsSolid Determine if this SurfaceBody is solid.
IsTransient Property that specified if this SurfaceBody is transient or not.
Name Gets and sets the name of the body.
Parent Property that returns the parent object from whom this object can logically be reached.
RangeBox Property that returns a Box object which contains the opposing points of a rectangular box that is guaranteed to enclose this object.
Type Returns an ObjectTypeEnum indicating this object's type.
Vertices Property that retrieves all vertices on the body.
Visible Gets and sets the visibility of the body.
Volume Property that returns the volume of the component in database units.
Wires Property returning the Wires collection object associated with this SurfaceBody.

Samples

Name Description
SurfaceBody Copy This sample demonstrates copying a surface body from one part to another. This is equivalent to the Promote command, but the API is much more flexible. In order for the sample to be self-contained, it creates two parts on the fly that will be used to demonstrate copying a body from one part to another. When copying a body into a part, you provide the surface body and a matrix to define its position in the new part. This sample creates a matrix based on the position of these parts within an assembly.
Client graphics texture-based color mapping This test applies texture coordinates expressing distance from the origin to 'the triangle mesh of whatever Part you have open. It then creates either a discrete-band or continuous color mapper and allows you to adjust the values of the mapper to change the range of values that map to various colors.
Create client graphics based on the solid body of the active part The sample also demonstrates the use of the slicing functionality available for client graphics.
Associative body copy The following sample demonstrates copying bodies (associatively and non-associatively) across parts in an assembly.
Sketch Add This sample demonstrates the creation of a sketch using the Sketches.Add method.
Create sheet metal rip feature This sample demonstrates the creation of a rip sheet metal feature.
Transient solid body creation The following sample demonstrates the creation of a transient solid block body. The newly created body is then displayed using client graphics in a part.
Transient surface body creation The following sample demonstrates the creation of a transient surface body consisting of a single rectangular face. The body is created in transient space and then copied over to a part document as a base feature.
Create primitive BRep This sample demonstrates the creation of primitive (solid) BRep.
Client graphics creation of 3D primitives This sample demonstrates the creation of 3D primitives (cylinder, cone, etc.) using client graphics.

Version

Introduced in Inventor version 4

 

And to create fillets you might want to look at this page

 

FilletFeatures Object

FilletFeatures Object

Description

The FilletFeatures collection object provides access to all of the objects in a component definition and provides methods to create additional FilletFeature objects.

Methods

Name Description
Add Method that creates a new FilletFeature. This method may be used to create fillet features of constant radius, variable radius or a combination of constant and variable radius. Setbacks may also be specified. The new FilletFeature is returned.
AddSimple Method that creates a new constant radius fillet where all fillets have the same radius. For more complex fillet features, the Add method of the FilletFeatures collection can be used.
CreateFilletDefinition Method that creates a new FilletDefinition object. The object returned by this method is used to define the inputs for a fillet feature and is provided as the argument to the Add method of the FilletFeatures collection.

Properties

Name Description
Application Returns the top-level parent application object. When used the context of Inventor, an Application object is returned. When used in the context of Apprentice, an ApprenticeServer object is returned.
Count Property that returns the number of items in this collection.
Item Returns the specified FilletFeature object from the collection.
Type Returns an ObjectTypeEnum indicating this object's type.

Samples

Name Description
Fillet Feature (Complex) This sample demonstrates creating a complex fillet. The result in this case has several different constant radii fillets and two edges that use variable radius, with one of these having a different radius defined along the edge.

Version

Introduced in Inventor version 5

 



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes