Align 3D annotation to a feature in the model tree

Align 3D annotation to a feature in the model tree

emilda.chiuye
Enthusiast Enthusiast
477 Views
3 Replies
Message 1 of 4

Align 3D annotation to a feature in the model tree

emilda.chiuye
Enthusiast
Enthusiast

Hello

I have tried reaching out to a number of Inventor advisors/ Collaborators/Contributors etc regarding this particular segment and no one seems to assist.

In hopes of finding a solution I have perused other posts where users are able to do this in an assembly environment which is far more complex than my simple task/request and they are receiving assistance.

I would like to automate the process of  creating a leader text in the model environment that points to a feature on the part. There are more than one features, and each is to be named differently. I have attached a snippet for better understanding.

emildachiuye_0-1628397153247.png

 

 

 

 

Dim oDoc As Inventor.PartDocument = ThisDoc.Document
Dim oDef As Inventor.PartComponentDefinition = oDoc.ComponentDefinition
Dim oTG As Inventor.TransientGeometry = ThisApplication.TransientGeometry

Dim oRepMan As Inventor.RepresentationsManager = oDef.RepresentationsManager
Dim oDesignViewReps As Inventor.DesignViewRepresentations = oRepMan.DesignViewRepresentations

Dim oFace As Inventor.Face = Feature.IsActive("Revolved Feature1")
Dim oAnnoPlaneDef As Inventor.AnnotationPlaneDefinition = oDef.ModelAnnotations.CreateAnnotationPlaneDefinitionUsingPlane(oDef.WorkPlanes(2))
Dim oLeaderPoints As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

oLeaderPoints.Add(oTG.CreatePoint(1, 0,1))

Dim oLeaderIntent As Inventor.GeometryIntent = oDef.CreateGeometryIntent("Revolved Feature1, FCW1 AT TUBE C ")
oLeaderPoints.Add(oLeaderIntent)
'Leader.ArrowheadType(kClosedArrowheadType) As ArrowheadTypeEnum 
Dim oLeaderDef As Inventor.ModelLeaderNoteDefinition = oDef.ModelAnnotations.ModelLeaderNotes.CreateDefinition(oLeaderPoints, "2000", oAnnoPlaneDef)
Dim oLeader As Inventor.ModelLeaderNote = oDef.ModelAnnotations.ModelLeaderNotes.Add(oLeaderDef)

 

0 Likes
Accepted solutions (2)
478 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @emilda.chiuye.  I don't know if you have solved this issue yet or not, but I haven't seen any follow up posts, so I assume not.  There are a couple of lines in your code that aren't going to work.

First of all this line:

Dim oFace As Inventor.Face = Feature.IsActive("Revolved Feature1")

It looks like you were attempting to get a face belonging to a feature named "Revolved Feature1".  You created the variable OK, but the value you are setting to it is obviously not going to work.  That 'Feature.IsActive()' phrase is a shortcut way of turning a feature on or off using a Boolean.  That phrase does not return or represent the feature being named within.  There are two ways to access the faces belonging to a feature, but I'll just mention the one way here for you.  You basically have to work your way down the API object model structure until you get to that feature, then it has a 'Faces' property which will give you access to the Faces that belong to that feature.  Also, as the property name suggests, a feature can have many faces, so you will have to decide which one to use.

Here is a little replacement code for that line that I believe should work for you:

Dim oFeature As RevolveFeature = oDef.Features.RevolveFeatures.Item("Revolved Feature1")
Dim oFace As Inventor.Face = oFeature.Faces.Item(1)

The next line that doesn't look right is the one where you are creating a geometry intent.  The text based geometry object you are specifying just won't work.  It has no idea what that is.  So my best guess is that you are intending on using the face of that feature here, as a way to attach the leader to the face.  Here is my best guess at a better value to fill in there.

Change This:

Dim oLeaderIntent As Inventor.GeometryIntent = oDef.CreateGeometryIntent("Revolved Feature1, FCW1 AT TUBE C ")

to this:

Dim oLeaderIntent As Inventor.GeometryIntent = oDef.CreateGeometryIntent(oFace)

Give those changes a try and see how it works out for you.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

emilda.chiuye
Enthusiast
Enthusiast
Accepted solution

Oh WOW!! You kind person, really are an Expert Elite Member😀

THANK YOU SO SO MUCH😀

0 Likes
Message 4 of 4

emilda.chiuye
Enthusiast
Enthusiast

oh noo! The "solved by Emilda" line is an error, my mouse froze and I clicked on the "accept solution" twice. What  a silly blunder 😞

emildachiuye_0-1628627063545.png

 

0 Likes