Community
Inventor Forum
Welcome to Autodeskโ€™s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results forย 
Showย ย onlyย  | Search instead forย 
Did you mean:ย 

VBA / API accessing MeshVertex, ~Edge and ~Face of imported STL-files

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
weiser
1204 Views, 18 Replies

VBA / API accessing MeshVertex, ~Edge and ~Face of imported STL-files

Hi there,

 

I' trying to create some tools for building CAD-models from imported STL-files.

Now I am trying to access the vertices, edges and faces given in the mesh.

 

As I found out the top-feature in the model-tree is an object of MeshFeatureSet, followed by an object of MeshFeature which should contain the geometry data ...

When looking at the properties of the MeshFeature-type the only thing I've found to be a container for something would be the Entities-property which is an MeshFeatureEntitiesEnumerator collection object.....

 

But after all I did not find how to access the geometry of the mesh itself....

 

Would be great if someone can switch on the light at the end of my tunnel ๐Ÿ˜‰

 

Regards

18 REPLIES 18
Message 2 of 19
Xun.Zhang
in reply to: weiser

Unfortunately, There is no such function for both UI and API to access mesh vertext, edge or face.

You can fit the mesh to normal berp geometries via command fit mesh face.

Untitled.png

Hope it helps!


Xun
Message 3 of 19
weiser
in reply to: Xun.Zhang

Hi @Xun.Zhang 

thanks for trying to help me out. I'd already tested the functions given be Inventor.... Unfortunately that's not too much.

The function where a freeform-surface is generated by selecting triangles with a pencil is quite nice, but the edges of the face are noch definable, and so the given surfaces have to be cutted manually.

 

That was the reason I decide to write some tools by myself. The main goal ist to pick three or four points on the surface, then "smoothed" edges along the surface are beeing generated (later on in the middle of the face-area railcurves will be added) and then the face will be generated.

 

Maybe the support-team can adopt my code later on and implement some new features ๐Ÿ˜‰

 

Regards

Message 4 of 19
johnsonshiue
in reply to: weiser

Hi! I could be wrong. I don't believe we expose the access in API. You could create a workpoint on a mesh vertex manually though. In the meantime, do you mind elaborating the need to have such access? The mesh vertices do not represent much design intent. To mesh, one vertex is just a point in the space, without any relationship to others.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 5 of 19
weiser
in reply to: johnsonshiue

Hi @johnsonshiue 

as I mentioned in the reply above I'm going to code some features for "semi-automatic" converting meshes into CAD-faces.

Right now I' using the MeshEnabler to convert an STL-file into CAD-triangulated-model. This is only done to access the geometric informations an the connectivity data given in the mesh by the vertices, edges and faces.

It seems to be a very data- and time-intensive way to convert the models and I guess it would be much more efficient to work with the imported STL-data directly .... but I may be wrong with that?!

So when beeing able to display the STL-geometry Inventor must have a data-structure for drawing, vertices, edges and faces. That lead me to the question how to access the mesh-data directly, without using the MeshEnabler.

Regards

Message 6 of 19
johnsonshiue
in reply to: weiser

Hi! The issue with mesh is that Inventor does not have robust and end-to-end mesh modeling workflows at the moment. Mesh is more for geometry referencing purpose in Inventor. If you want to alter the mesh geometry, you will run into limitations. Let's say you convert the mesh into body geometry. What do you plan to do with such parts?

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 7 of 19
weiser
in reply to: johnsonshiue

Hi @johnsonshiue 

I'm trying to find a way to build CAD-models from "physically designed" models which have been scanned and build up as an triangulated surface. A second field would be the building of bone structures from readilogical data.

So there is no need in modifying the mesh itself! I just need the geometric data (vertices, edges, faces ... with it's connectivity) AND the possibility for the user to select items (vertices {edges, faces}) of the model.

I hope this outlines clearly what I'm trying to do ....

Regards

Message 8 of 19
johnsonshiue
in reply to: weiser

Hi! The mesh geometry is indeed named and tagged, which is why you can create drawing views of mesh and also you can create workplanes based off mesh face. Let me work with API experts to find out if such API calls are available.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 9 of 19
MjDeck
in reply to: johnsonshiue

@weiser , each MeshFeatureEntity under the MeshFeature object contains properties: CoordinateSet and CoordinateIndexSet. These provide access to the vertices and triangles that make up the mesh. This is very low-level data: you would have to write code to recognize something like faces in it.
I don't think the individual vertices and triangles are selectable in the UI.  But maybe you could create a different type of entity out of them, and that would be selectable.


Mike Deck
Software Developer
Autodesk, Inc.

Message 10 of 19
weiser
in reply to: MjDeck

Hi ,

when looking at the data structre of CoordinateSet and CoordinateIndexSet, it didn't make any sense to me at all .... Though there might to be a higher force understanding it ๐Ÿ˜‰

When exploring the regular data structures the names are quite simple to understand like faces, edges, vertices and so on...

Would be great to get some further information about that.

Thanks in advance!

Message 11 of 19
weiser
in reply to: MjDeck

Hi @MjDeck , @johnsonshiue , @Xun.Zhang 

here are the first results what I'm doing with the mesh-models.....

https://forums.autodesk.com/t5/inventor-forum/tool-curves-on-mesh/td-p/8830791

Though it's a little bit slow my idea was to to bypass the Mesh-Enabler tool for converting the imported STL-file to an pickable and structured data

Best regards

Message 12 of 19
MjDeck
in reply to: weiser

@weiser , I attached an iLogic rule that will list the data in the MeshFeatureEntities. To see the output, use the checkbox under View > User Interface > iLogic Log (on the ribbon) to make the iLogic log visible. It should be relatively easy to convert this code to VBA.
The CoordinateSet contains a list of vertex coordinates as doubles: X1,Y1,Z1,X2,Y2,Y2,...
The CoordinateIndexSet contains a list of indices into the coordinates. If you divide the list into groups of three, each group defines a triangle.


Mike Deck
Software Developer
Autodesk, Inc.

Message 13 of 19
MjDeck
in reply to: MjDeck

Typo: it should be X2,Y2,Z2,...


Mike Deck
Software Developer
Autodesk, Inc.

Message 14 of 19
MjDeck
in reply to: MjDeck

Maybe Inventor is not the best for what you're doing. Have you looked at MeshMixer?


Mike Deck
Software Developer
Autodesk, Inc.

Message 15 of 19
weiser
in reply to: MjDeck

Thanks for the information. That's what I found by now. But these are only coordinates - I guess for the vertices. How are they connected to edges and faces?

Regards

Message 16 of 19
weiser
in reply to: MjDeck

Thanks for you answer. I have this tool already installed ... But the MesMixer is only for "healing" or modifying meshes... What I'mtrying to get are CAD-spline-surfaces....

Regards

Message 17 of 19
MjDeck
in reply to: weiser

Edges and faces are not available through the API. The only thing you can get are the raw triangles.
The CoordinateIndexSet contains a list of indices into the vertex coordinates. If you divide the list into groups of three, each group defines a triangle.

This video shows how Fusion 360 can be used to smooth surfaces and a solids over a mesh.


Mike Deck
Software Developer
Autodesk, Inc.

Message 18 of 19
weiser
in reply to: MjDeck

Hi @MjDeck 

thanks again for the information.

-> data sructure of the mesh-data: As I mentioned I acutally use the mesh-enabler get sone useful data structure. When beeing finished with programming of my tool I will take a look at the mesh-list of indices again. But I don't want to leave more construction areas unfinished ๐Ÿ˜‰

-> video: I allready installed Fusion. And yes, that's nearly what I'm trying to do. But there are some reasons, why I don't want to use Fusion:

-1- I want to stay in the Inventor-GUI, because everybody is used to work with it

-2- I think that the workflow of the Fusion tools are not that handy e.g.

      ... when building a cross section (which is also availible in Inventor) you have to setup spline-connection manually. I have coded already a tool for doin this automatically

     ... when projecting a t-nurbs-face onto the mesh-surface, you are not that flexible in selecting the desired geometric regions.

So, after all thanks for your help!

Message 19 of 19
weiser
in reply to: weiser

Hi @MjDeck@johnsonshiue, @Xun.Zhang,

just to let you know what I've been doing so far.

Here is the tool for generating CAD-curve-meshes for CAD-surfaces on a triangulated mesh-surface:

https://forums.autodesk.com/t5/inventor-forum/tool-surfaces-on-mesh/td-p/8850954

Regards

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report