retrieve sketch plane and features programmaticly

retrieve sketch plane and features programmaticly

Anonymous
Not applicable
1,317 Views
4 Replies
Message 1 of 5

retrieve sketch plane and features programmaticly

Anonymous
Not applicable

Hello,

        I'll get straight to it - I have a part with multiple features such as extrudes, sweeps, lofts etc. For each feature in the part i need to get:

  1. the dimensions of the sketch
  2. the plane that the sketch was created on
  3. the feature variables e.g extrusion length.

(The actual dimension values are not improtant, more the ability to retrieve them)

 

example below:

 

a cylinderical prism (smartie tube) created using 1 circular extrusion. Information retrieved:

  • diameter dimension of edge 1
  • Drawn on the top plane
  • extrusion length of 150mm

in the future it could be a cube, or a more complex sketch so im wondering if i can utilise the 'retrieve dimensions' function somehow.

 

another example (ideal information retrieved from part):

 

Feature 1 (extrusion) :

  • 30x30mm square (linear dimension edge 1 - edge 2 & linear dimension edge 3- edge 4)
  • extrusion length 140mm
  • sketch plane: Right

Feature 2 (revolve):

  • dodecahedron sketch with obscure rectangular pattern (retrieve dimensions - linear edge 1-edge 2 etc...)
  • revolved angle: 90 degrees & axis used to revolve
  • sketch plane: Top 

To try and explain myself regarding the retrieve dimensions. I need to get all the dimensions that the user used to contrain the part when they were creating it. So if i could get an output from my code that sais; linear dimension 1 from edge 1-edge 2. angular dimension 1 from edge 3-edge 2, linear dimension 2 from edge 7-edge2... I could work with that. 

 

I know I am asking a lot, if anyone could offer me some pointers to get started, it would be greatly apreciated and I'll do the rest of the digging myself. I am an intermediate programmer that has worked with Inventor API for a while, just never with sketches and existing features before 😛

 

Thanks in advance

0 Likes
1,318 Views
4 Replies
Replies (4)
Message 2 of 5

philippe.leefsma
Alumni
Alumni

You may want to start from scratch, here is the link to the Inventor API Material:

 

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

 

Each feature has different properties. Please take a look at ExtrudeFeature and RevolveFeature in the API Help Files for a start. Another great way to discover how to retrieve a property and where to look for is to use the VBA debugger, it provides a powerful way of seeing "live" objects in Inventor.

 

For example, Extrusion.Profile.Parent returns the sketch the extrusion is based on, same for revolve.

 

I hope it helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

From the Feature you can go: Feature >> Profile >> ProfilePath >> SketchEntity >> Sketch

Inside the Sketch you'll find the DimensionConstraints collection.

Depending on the feature it will have different properties, so you'll have to handle them differently.

 

It's worth looking around in the VBA Watch window to find how to get to certain properties: http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html

 

I hope this helps.

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks for the support both of you, I will have a good look through the API training material - no-ones pointed that out to me before. Can I also add that this is why Autodesk products are in one respect much better that Solidworks... resources are made a valiable! 

 

Anyway, the 'Extrusion.Profile.Parent' works a treat so thanks 🙂 . The 'Feature >> Profile >> ProfilePath >> SketchEntity >> Sketch' Is also another piece to the puzzle so thanks again.

 

 However, im struggling to find all the corrrect extensions (if you'd call them extensions, mayby paths). See my attached screenshot to see how Visual Studio (ive also tested it in Inventos VBA editor), cant find the ProfilePath after Feature.Profile..... Do you know why its not finding the ProfilePath.SketchEntity?

 

 

0 Likes
Message 5 of 5

adam.nagy
Autodesk Support
Autodesk Support

A Profile can have multiple ProfilePath's, so you'll find it under Item, e.g.  oExFeat.Profile.Item(1) is a ProfilePath



Adam Nagy
Autodesk Platform Services
0 Likes