Retrieve 3D Model dimensions command fails

Retrieve 3D Model dimensions command fails

KarolisS38L4
Participant Participant
555 Views
7 Replies
Message 1 of 8

Retrieve 3D Model dimensions command fails

KarolisS38L4
Participant
Participant

I am looking for a way, to retract ModelAnnotations from a 3D model into a drawing document.

I did found a relatable post about this, but it works for a single drawing view.
https://forums.autodesk.com/t5/inventor-programming-ilogic/retrieve-3d-model-annotations-on-drawing-...

The latter answer retrieves General dimensions, which are Inventor Feature created dimensions, such as sketches, extrusions, etc.. Correct me if I am wrong, but that's what I got in testing.

So I wanted to use the first approach by executing Inventor command in iLogic, this is my script.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
oDDoc.SelectSet.Clear()

For Each oSheet As Inventor.Sheet In oDDoc.Sheets
	Dim previousView = Nothing
	For Each oView As DrawingView In oSheet.DrawingViews
		If previousView IsNot Nothing
			oDDoc.SelectSet.Remove(previousView)
		End If
		
		previousView = oView
		oDDoc.SelectSet.Select(oView)
		Trace.WriteLine("View name: " + oView.Name)
		
		ThisApplication.CommandManager.ControlDefinitions.Item("DrawingRetrieveDimsCmd").Execute
		ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_OKCmd").Execute
	Next
Next

 
To replicate it you can try to run it on a given drawing, it retrieves a dimension only for a single view and that view from time to time changes for some reason..

Maybe I am not using SelectSet method correctly, if you know a better way, please tell me.

Thanks in advance and have a nice day!


Accepted solutions (2)
556 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

Hi @KarolisS38L4.  The main thing I see that looks wrong in your code, is that you are not activating each sheet as you iterate through them.  It can not select something that is on some other sheet that is not the active sheet.  The Sheet object has a method called Activate that you can use for this purpose.  And if needed, you can record which one was originally active before you start the loop, then activate that same original sheet again after the loop, to make sure you end up on the same sheet where you started.  Next I would suggest replacing those 4 lines of code within your loop of the sheets (that are attempting to remove just the previous sheet), with the same line of code you are using at Line 6.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 8

WCrihfield
Mentor
Mentor
Accepted solution

There is also another property of the DrawingView object that you will want to make sure is set the right way.

DrawingView.Include3DAnnotations 

In fact, that one property by itself has solved multiple forum inquiries about getting 3D annotations (which the ModelDimension is a member of) to show up in drawings.  Other examples used the additional GeneralDimensions.GetRetrievableDimensions method before using the GeneralDimensions.Retrieve method, just to get an 'initial' collection to start with, then created their own ObjectsCollection (and put those into it), then dug into the model to get the specific 3D annotation dimensions they wanted, then supplied that collection to the Retrieve method, as the second input.  But some of those examples started trying to reach down multiple levels, into sub assemblies, and parts within sub assemblies, to retrieve 3D dimensions into the drawing of the main assembly.  Not sure that is possible, because I never needed it, but I did try to help with that too in one or two places.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 8

KarolisS38L4
Participant
Participant

Thank you for a quick reply,

the issue applies on a drawing document with a single and only active sheet.

It loops through drawing views and prints it's names, but it does not retrieve the annotations.


0 Likes
Message 5 of 8

KarolisS38L4
Participant
Participant

 

KarolisS38L4_0-1717165242024.png


I did try to use those methods, but I get 0 count of retrieved dimensions when I am using a file created from a step (with no features).

The only dimensions I could retrieve from those were sketch dimensions (didn't test for extrusions), but no 3DModelAnnotations.

Will check out the DrawingView.Include3DAnnotations property, didn't test it. Thanks!

0 Likes
Message 6 of 8

WCrihfield
Mentor
Mentor

OK.  That one setting is essentially what you will sometimes (only when available) see on the 'Recovery Options' tab of the Drawing View edit dialog, below where it asks about surface / mesh bodies.  There is also sometimes a checkbox option in that area for including user work features.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 8

KarolisS38L4
Participant
Participant

Well that property did not solve the issue.

0 Likes
Message 8 of 8

KarolisS38L4
Participant
Participant
Accepted solution

Probably event to add dimensions is fired only when a value of a property has been changed.

So in order to work it consistently first I needed to define that value as False

oView.Include3DAnnotations = False
oView.Include3DAnnotations = True
0 Likes