Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generate drawing view from saved view with 3D annotations

6 REPLIES 6
Reply
Message 1 of 7
Fabian_perree
283 Views, 6 Replies

Generate drawing view from saved view with 3D annotations

Hi there,

 

i'm trying to generate drawing view with camera position and 3D annotation from a part :

 

Fabian_perree_0-1718868361804.png

 

When using the code below it seems it doesn't use my pre saved view but only the view from the right and I don't keep the 3D Annotations visibilities I've saved in my view (all 3d annotations are imported).

 

My goal is to have only some 3D annotations in my left view and some other in my right view. Today the first view generated have all the annotations and the other none.

 

Any tips ?

 

oViewRight = oSheet.DrawingViews.AddBaseView(oDoc, oPosRight, 0.25, _
                                                 ViewOrientationTypeEnum.kRightViewOrientation, _
                                                 DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)
	oViewRight.Include3DAnnotations = True
	oViewFront.DisplayTangentEdges = True

 

Fabian Perrée
Giùp.fr | LinkedIn

Ce post vous a été utile ? N'hésitez pas à aimer ce post.
Ce post a-t-il répondu à votre question ? Cliquez sur le bouton Accepter la solution.

EESignature

Cliquez ici pour accéder à toutes mes formations en ligne
Inventor 2022 : Modélisation et documentation de systèmes mécaniques
6 REPLIES 6
Message 2 of 7
WCrihfield
in reply to: Fabian_perree

Hi @Fabian_perree.  This is not really something that I have had to do before, but I would suspect that you would have to do the following:

  • When specifying 'ViewOrientation', try using the ViewOrientationTypeEnum.kSavedCameraViewOrientation.
    • There are a couple other variations that could be tried, but this one sounds like the best match.  However, you would also want to include the next optional input labeled 'ModelViewName', where that would be the name of the DesignViewRepresentation that you want the view to be using.  But it says this may fail, if it is a view of a part, and not of an assembly or presentation, even though parts have them too.
    • If that does not work, then try using the 'kArbitraryViewOrientation' variation, then include the actual Camera object for the optional input labeled 'ArbitraryCamera', later within that AddBaseView method.
  • If you do not want all of the possible 3D annotations to be automatically included in the view when it gets created, then you may have to use something like the GeneralDimensions.GetRetrievableDimensions method and/or the GeneralDimensions.Retrieve method.  You get get to those through DrawingDocument.ActiveSheet.DrawingDimensions.GeneralDimensions collection object.  It may only be able to retrieve 3D annotations from the immediate model reference though, instead of from deeper references.  There are several forum discussions about retrieving dimensions into drawing views by code that can be found and reviewed, if needed.

Just some initial thoughts.

Edit:  I know of two different places to specify that you want to include 3D annotations.  One can be seen if you click the little gear/cog icon next to where we specify the design view, within the smaller pop-up dialog, like you are showing in your initial post.  I am not sure how to access that one by code at the moment.  However, the other one is on the 'Recovery Options' tab of the Drawing View editor dialog,  but is only visible / available when there are some 3D annotations in the immediately referenced model.  That is the one you are accessing in your code example above.  Sometimes setting that to True is all that is needed to include 'all' 3D annotations that can be seen by that view's line of sight.  Trying to manage only including some of them is going to be challenging to do by code though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7
Fabian_perree
in reply to: WCrihfield

Hi @WCrihfield,

 

Thanks a lot for your very complete answer !

I'll have a try with the differents way you gave to me, thanks a lot.

 

Best Regards

Fabian Perrée
Giùp.fr | LinkedIn

Ce post vous a été utile ? N'hésitez pas à aimer ce post.
Ce post a-t-il répondu à votre question ? Cliquez sur le bouton Accepter la solution.

EESignature

Cliquez ici pour accéder à toutes mes formations en ligne
Inventor 2022 : Modélisation et documentation de systèmes mécaniques
Message 4 of 7
KurtDR
in reply to: Fabian_perree

Hi, 

 

I do this too and works perfect for me under the condition that you apply a correct Annotation Plane parallel to the view. I do this for every dimension even if unnessecary - to be sure 😀

KurtDR_0-1718969064394.png

 

Message 5 of 7
Fabian_perree
in reply to: KurtDR

Hi @KurtDR,

 

I'll give a try to select another plane but as I've got one right and one left view the planes are parallels and all the annotations are imported in one view.

 

But maybe I didn't understand, could you show me the code you're using in Ilogic?

 

I've got good result with getting annotation from sketches with their names but I'll love to import directly the view I've already made...

Fabian Perrée
Giùp.fr | LinkedIn

Ce post vous a été utile ? N'hésitez pas à aimer ce post.
Ce post a-t-il répondu à votre question ? Cliquez sur le bouton Accepter la solution.

EESignature

Cliquez ici pour accéder à toutes mes formations en ligne
Inventor 2022 : Modélisation et documentation de systèmes mécaniques
Message 6 of 7
WCrihfield
in reply to: Fabian_perree

I did some additional testing on my end and found out that it seems like what you are trying to do is very possible, with the right preparations ahead of time.

  • First of all, as @KurtDR mentioned, when you initially create the 3D model dimensions and/or other 3D model annotations within the model, you must make sure they are on an annotation plane that can be seen from the camera angles you want to look at the model from when you create the views for it in the drawing.
  • Next, make sure you have a different DVR (DesignViewRepresentation) for each view you want to show in the drawing.
    • And while each DVR is active in the model, set the 'visibility' of those 3D model annotations the way you want them for that specific view.
    • Later, when you create the drawing view, and set that view to this DVR, that will help control which 3D model annotations are included in that view.
  • Next, in code for creating/adding the drawing views:
    • Create a NameValueMap and add the options into it that are appropriate for the type of model being shown in that view, to set certain settings the way you want them, and supply that as the input being asked for, labeled 'AdditionalOptions'.
    • You can review the documentation on the AddBaseView online help page for more about the names of those options, what model types they are for, and what they do.
    • One of those options is for that 'Include3DAnnotations' setting that you see within that smaller dialog.  And I can confirm that it works as expected (when the other preparations have been set up properly).

I had a weldment type assembly I was working on, added several 3D model dimensions, and a couple 3D annotation Leader Text notes.  I did this for two different views of the model, and made sure there was a DVR for both views.  After all annotations were present, I made sure only the ones I wanted to see in each view were visible while their DVR's were active, so the DVR's would record those visibility settings.  I even turned one or another off (visibly) in each view, as an additional test.  When I created the drawing view by code, the way I mentioned above, the views, and the specific 3D model annotations being automatically included in them, were just as expected (only the ones visible in the specified DVR).  The reason I am specifying 'right' view orientation, but then 'FRONT' DVR, is due to ViewCube being different than what I would prefer, but I do not like to modify the ViewCube from its default.  Instead I generally design stuff with the ViewCube's orientation in mind, so that it ends up the way I want, obviously with some exceptions here and there, when it is not important.

 

Below is a modified version of the code I used when testing, that worked OK for me.

Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews

Dim oBView As DrawingView = Nothing
Dim sModelFile As String = "C:\Temp\MyWeldment.iam"
Dim oModelDoc As Inventor.Document = ThisApplication.Documents.Open(sModelFile, False)
Dim oPosition As Inventor.Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width / 4, oSheet.Height / 4)
Dim dScale As Double = (1/23)
Dim oVO As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kRightViewOrientation
Dim oVStyle As DrawingViewStyleEnum = DrawingViewStyleEnum.kShadedDrawingViewStyle
Dim sMViewName As String = "FRONT"
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("WeldmentFeatureGroup", WeldmentFeatureGroupEnum.kWeldsFeatureGroup)
oOptions.Add("DesignViewRepresentation", "FRONT")
oOptions.Add("DesignViewAssociative", True)
oOptions.Add("Include3DAnnotations", True)
Try
	oBView = oViews.AddBaseView(oModelDoc, oPosition, dScale, oVO, oVStyle, sMViewName, , oOptions)
Catch ex As Exception
	Logger.Error("AddBaseView method error." & vbCrLf & ex.Message & vbCrLf & ex.StackTrace)
End Try

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)

Message 7 of 7
Fabian_perree
in reply to: WCrihfield

Thank you again @WCrihfield,

 

Unfortunatly my document is a part doc so, as specified in the help regarding ModelViewName :

 

This argument is ignored if the document type specified by the Model argument is a part file (.ipt)

I could make an assembly with only my part inside but I don't think it's a a good practice.

 

For now I think i'll do with this :

 

 Dim  oDims As  GeneralDimensions
 oDims = oSheet.DrawingDimensions.GeneralDimensions
 
 
 Dim  oRetrievableDims As  ObjectCollection
 oRetrievableDims _
 = ThisApplication.TransientObjects.CreateObjectCollection
 oRetrievableDims = oDims.GetRetrievableDimensions(oViewFront)
 
 If  oRetrievableDims.Count > 0 Then 
     Dim  dimsEnum As  GeneralDimensionsEnumerator
     dimsEnum = oDims.Retrieve(oViewFront)
 
     Dim  paramName As  String 
     Dim  oDim As  GeneralDimension
     For  Each  oDim In  dimsEnum
         If  oDim.Retrieved Then 
             paramName = oDim.RetrievedFrom.Parameter.Name
 
             If  paramName <> "d3"  And  _
             paramName <> "d4"  Then 
                 oDim.Delete()
             End  If 
         End  If 
     Next 
 End If

 to retrieve only the dimensions I need in each view. 

Fabian Perrée
Giùp.fr | LinkedIn

Ce post vous a été utile ? N'hésitez pas à aimer ce post.
Ce post a-t-il répondu à votre question ? Cliquez sur le bouton Accepter la solution.

EESignature

Cliquez ici pour accéder à toutes mes formations en ligne
Inventor 2022 : Modélisation et documentation de systèmes mécaniques

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report