INVENTOR API DRAWING AUTOMATION

INVENTOR API DRAWING AUTOMATION

ksofias
Community Visitor Community Visitor
383 Views
4 Replies
Message 1 of 5

INVENTOR API DRAWING AUTOMATION

ksofias
Community Visitor
Community Visitor

Hi! I am new to inventor API and vba. What i am trying to do is to create some dimensions and some centerlines on my drawing views. What i cant understand is if this is possible without using workpoints or workplanes or attributes. I do not want to use iLogic, only API and i just need some general dimensions and centerlines. More specifically i design only revolved parts so i need the largest diameter, the smallest diameter and the heights of the part. Thank you in advance! 

0 Likes
384 Views
4 Replies
  • API
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

Hi @ksofias 

I would suggest you start with the VBA samples that exist within the API help. See help page and sample here. Your request is reasonably complicated so you will need to put in a considerable amount of work to place the dimensions especially without attributes. You would normally name a specific face/edge to help you target where to position dimensions. Any reason why you would not want to use attributes?

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 5

mat_hijs
Collaborator
Collaborator

The little experience I have in drawing automation has taught me that it's most likely possible to avoid using work features and attributes, but in many cases I think it's not feasible. Further, the iLogic snippets make it a LOT easier than using straight API so I would suggest that if you can, use iLogic. This article by @JelteDeJong may help you: Jelte de Jong (hjalte.nl)

Message 4 of 5

davidt162003
Advocate
Advocate

Like the other Guy said its probably a little more complicated than you think but here's how you'd get the centrelines. You might need to change the code slightly if your using a part rather than a occurrence in an assembly(you wouldn't need to create a proxy). The Axis name would just be "Y Axis", "X Axis" or "Z Axis".

 Friend Function CenterlineFromNamedPartAxis(View As DrawingView, Occurrence As ComponentOccurrence, AxisName As AxisEnum, Optional Visible As Boolean = False) As Centerline
     Try
         Dim PartAxis As WorkAxis = Occurrence.Definition.WorkAxes(AxisName)
         Return _CenterlineFromAxis(View, Occurrence, PartAxis, Visible)
     Catch ex As Exception
     End Try
 End Function
 Private Function _CenterlineFromAxis(View As DrawingView, Occurrence As ComponentOccurrence, Axis As WorkAxis, Optional Visible As Boolean = False)
     Dim Drawsheet = View.Parent
     Dim AxisProxy As WorkAxisProxy
     Occurrence.CreateGeometryProxy(Axis, AxisProxy)
     Dim CenterLine = Drawsheet.Centerlines.AddByWorkFeature(AxisProxy, View)
     CenterLine.Visible = Visible
     Return CenterLine  
 End Function

 Once you have the centre line objects you can use either end of those to get your height and max width. Then depending on what your models doing the difficulty of finding the minimum width will vary  

HII
Message 5 of 5

JelteDeJong
Mentor
Mentor

@ksofias wrote:

Hi! I am new to inventor API and vba. 


Just a quick response. If you are new to Inventor automation then don't look at VBa. It's obsolete and support from Microsoft stopped in 2010! In new versions of inventor it's a separate installation only to be backwards compatible. it's beyond me why Autodesk example are still written for VBa. For a complete rant (and real information) from me about VBa in inventor have a look at this blog post. Anyway, please have a look at iLogic instead of VBa.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com