Code for retrieve model Annotations in drawing

Code for retrieve model Annotations in drawing

richie_rQYQ8U
Contributor Contributor
908 Views
7 Replies
Message 1 of 8

Code for retrieve model Annotations in drawing

richie_rQYQ8U
Contributor
Contributor

Hi All,

 

Is there a code for retrieving model annotations in the drawing ?

 

Thank you

 

0 Likes
909 Views
7 Replies
Replies (7)
Message 2 of 8

BM_Ashraf
Advocate
Advocate

Hi,

This is the Syntax

GeneralDimensions.Retrieve Method

Parent Object: GeneralDimensions 

Description

Method that retrieves sketch and/or model dimensions into the drawing.

Syntax

GeneralDimensions.Retrieve( ViewOrSketch As Object, [DimensionsToRetrieve] As Variant ) As GeneralDimensionsEnumerator 

 

So, You need a Drawing sheet and Drawing view


Ex.

 

Dim oDrawView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Please select a View, Esc to Cancel ")
If oDrawView Is Nothing Then Exit Sub 
Dim oSheet As Sheet = oDrawView.Parent

oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oDrawView)

 

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.

Blue Mech

Add-ins for Inventor!

0 Likes
Message 3 of 8

d_bouvy
Contributor
Contributor

Hello,

It seems impossible to make model annotation of an assembly visible in a drawing with VBA... Is anyone know this ?

The code above put all dimensions of sketches and features, but not model annotations....

0 Likes
Message 4 of 8

WCrihfield
Mentor
Mentor

Hi @d_bouvy.  Have you already tried turning this setting on?

DrawingView.Include3DAnnotations 

Also, if those 3D model annotations were not directly created within the main/top assembly, then you would need to dig for the 'real' ones within the components, then get a reference to their 'proxy' representations within the main/top assembly, then gather those proxy versions to be included in the drawing.  The 'retrieve' process generally only works for top level stuff in the main model, not for stuff below that level.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 8

richie_rQYQ8U
Contributor
Contributor

Hi Thank you for your reply,

 

No i didn't try that 

 

Can you show me how to do that please?

0 Likes
Message 6 of 8

WCrihfield
Mentor
Mentor

Sure.  Below is a link to a similar post I responded to in a similar way about 2 years ago which contains a very basic iLogic example.

https://forums.autodesk.com/t5/inventor-programming-ilogic/retrieve-3d-dimensions-placed-on-an-assem... 

But I can post another example here too.  This example will iterate through each sheet, and each view on each sheet, setting that view property to True on each one.  I believe this setting is similar to the one you see on the 'Recovery Options' tab of the Drawing View editing dialog, where there is a checkbox named 'All Model Dimensions'.

Sub Main
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then Logger.Debug(iLogicVb.RuleName & " exited (wrong DocumentType)") : Return
	Dim oSheets As Inventor.Sheets = oDDoc.Sheets
	Dim oASheet As Inventor.Sheet = oDDoc.ActiveSheet 'record originally active sheet
	For Each oSheet As Inventor.Sheet In oSheets
		oSheet.Activate
		Dim oViews As DrawingViews = oSheet.DrawingViews
		If oViews.Count = 0 Then Continue For 'skip to next sheet
		For Each oView As DrawingView In oViews
			'<<< setting that Boolean type property to True here >>>
			oView.Include3DAnnotations = True
		Next 'oView
		oSheet.Update
	Next 'oSheet
	'restore originally active sheet to active again
	If oDDoc.ActiveSheet IsNot oASheet Then
		oASheet.Activate
	End If
End Sub

At the following link, I had also responded to another similar forum post about 3 1/2 years ago where I showed a code way to simulate the manual process of retrieving model annotations in a drawing, but I generally do not recommend using a command execution and SendKeys type routine anymore, due to the inherent dangers of using the SendKeys methods (the keystrokes could potentially get sent to the wrong place, which could have an unknown effect).

https://forums.autodesk.com/t5/inventor-programming-ilogic/retrieve-model-annotations-ilogic/m-p/975... 

There are also other forum posts out there on this subject too, which may offer more insights, and different code examples.

 

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 8

richie_rQYQ8U
Contributor
Contributor

thank you for your solution @WCrihfield
Good thing is the code is working
but i can use the code one time next time if i try it
it was not working

i need to double click the view to get the annotations.

0 Likes
Message 8 of 8

d_bouvy
Contributor
Contributor

Hello,

 

Thanks, it works !

I don't know why, but with CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute, dimensions don't appear when I was printing in PDF.

Now it seems great with drawingview.include3Dannotations

0 Likes