Retrieve Model annotations iLogic

Retrieve Model annotations iLogic

Anonymous
Not applicable
3,067 Views
12 Replies
Message 1 of 13

Retrieve Model annotations iLogic

Anonymous
Not applicable

Hello Everybody,

Does anybody know how to use the "Retrieve Model Annotations" function with iLogic.
I was able to retrieve dimensions automatically but I need to retrieve also 3D annotations : Manually it can be done by clicking the retrieve annotations icon from the ribbon and selecting the view, but I wish to implement this in my iLogic code

Can you please help ?
Thanks in advance

0 Likes
Accepted solutions (2)
3,068 Views
12 Replies
Replies (12)
Message 2 of 13

WCrihfield
Mentor
Mentor
Accepted solution

The command is called "DrawingRetrieveDimsCmd".

You can simulate clicking that button by executing it like this by code.

ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute

But you will most likely have to select the right Tab, and the View you want it to act upon.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 13

WCrihfield
Mentor
Mentor
Accepted solution

I threw a little more together with this code, but for some irritating reason, it won't finish and completely close out of the process, without loosing the retrieved dimensions.  I've tried several things (as you can see by all the commented out lines at the end of my code), but nothing has completely worked as I had hoped for.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MessageBox.Show("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.", "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(3)
oDDoc.SelectSet.Select(oView)
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute'2(True)
'System.Windows.Forms.SendKeys.SendWait("{ENTER}{ESC}")
'System.Windows.Forms.SendKeys.SendWait("{ENTER}")
'ThisApplication.UserInterfaceManager.DoEvents()
'System.Windows.Forms.SendKeys.SendWait("{ESC}")
ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_OKCmd").Execute
'ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_ApplyCmd").Execute
'ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_CancelCmd").Execute

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 13

WCrihfield
Mentor
Mentor

@Anonymous 

Basically, after selecting the view and executing the command, it is then waiting for you to select which of the annotations it is showing you a preview of.  It appears there still needs to be a bit of code here to do the additional selection, so it won't think you didn't want any of them, then close the process.  Once that selection is done, you should be able to use one of the code methods to send the 'OK' to the process.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 13

Anonymous
Not applicable

Thank you @WCrihfield 
The code worked perfectly !

0 Likes
Message 6 of 13

emilda.chiuye
Enthusiast
Enthusiast

Hello @WCrihfield

My I ask for your assistance in placing 3D leader annotations to a specific feature? I have a number of features and each require an annotation to better differentiate. The code I have placed below works only if you have a command manager that prompts the face of where the leader should be. I want to set the code up that it points to Revolved feature 1 or 2 or 3, you get the idea. 

Would you be able to assist me considering you have managed this already?

 

 

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(oFace)
oLeaderPoints.Add(oLeaderIntent)
Dim oLeaderDef As Inventor.ModelLeaderNoteDefinition = oDef.ModelAnnotations.ModelLeaderNotes.CreateDefinition(oLeaderPoints, "2000", oAnnoPlaneDef)
Dim oLeader As Inventor.ModelLeaderNote = oDef.ModelAnnotations.ModelLeaderNotes.Add(oLeaderDef)

 

 

0 Likes
Message 7 of 13

m.den.ouden
Advocate
Advocate

Right way to this is like this

oDrawingDoc.SelectSet.Select(oDrawingView)
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute
ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_ApplyCmd").Execute
System.Windows.Forms.SendKeys.SendWait("{ESC}")

 Should do the trick!

0 Likes
Message 8 of 13

c.bloedorn
Enthusiast
Enthusiast

Probably a little late, but I thought someone might come across this post in the future.

This another option to retrieve model annotations with the benefit of being able to choose which dimensions to include:  (In the example I'm limiting the dimensions to retrieve to the first sketch)

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawing view")
'Collection of dimenstions from first sketch only
Dim oDimCollect As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection(oView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition.Sketches.Item(1).DimensionConstraints)

oDoc.ActiveSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView, oDimCollect)

  

Message 9 of 13

m.den.ouden
Advocate
Advocate
But then it is not automation anymore of youll have to pick things yourself. But thanks any way. I already wrote great functions that work really good.
Message 10 of 13

c.bloedorn
Enthusiast
Enthusiast

I only added the pick so anyone can simply copy the code and test it in any drawing.

The code can then be altered to automate retrieving annotations to their needs.

I simply wanted to offer an alternative solution, as it worked better for what I was trying to achieve.

Message 11 of 13

emilda.chiuye
Enthusiast
Enthusiast

 Hello @m.den.ouden 

Based on your response where you say you have already written great functions that work well, may I request how you achieved this by sharing the code on this forum? My understanding of programming is quite primitive, however, I would like to automate critical dimensions that would be useful for manufacturing and I would like to include machining notes where applicable.

I have used the "Retrieve Model Annotations" function, but I find it a bit messy, and I spend time removing the unwanted dimensions which are placed everywhere, and they tend to overlap.

 

 

0 Likes
Message 12 of 13

m.den.ouden
Advocate
Advocate

Yeah sure. But I need a part file and the existing drawing. then I can show you. It is no basic code. it's all writen classes and functions. If you are not a programmer then maybe it is hard to implement.

0 Likes
Message 13 of 13

emilda.chiuye
Enthusiast
Enthusiast

Hello @m.den.ouden 

I am not a programmer but with Autodesk anyone can imagine and create ANYTHING 🙂

So I am VERY optimistic and it is the new year so programming is definitely a language I must learn in order

to keep up with the Cad Design world!

I am an optimist but I am also a realist, if it is too complex to implement I will reach out to @c.bloedorn to see 

how I can apply the code that was provided to be used for more than one view. 

 

Anyway, here is a part file that can be used for this automation exercise.

Thanks

 

 

0 Likes