API for Custom view orientation with Look At

API for Custom view orientation with Look At

sriYDVN4
Observer Observer
1,371 Views
3 Replies
Message 1 of 4

API for Custom view orientation with Look At

sriYDVN4
Observer
Observer

I have a model that rotates about z axis and every time the angle is changed the view get rotated in z direction, resulting in improper view representation.  

now I follow the command as follows but this needs to be done for drawing automation:

custom view orientation->Look At 

Select a plane and then finish custom view orientation.

Any help with API code for this would be of great support.

 

0 Likes
1,372 Views
3 Replies
Replies (3)
Message 2 of 4

bhavik4244
Collaborator
Collaborator
Message 3 of 4

sriYDVN4
Observer
Observer

Thank you for your response but the iRule set is not reflected in the drawing, it applies only for 3D model.

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @sriYDVN4.  To do what you seem to be wanting, would require you to manipulate the camera of a view within the model document by code, then capture that camera object for use in the line of code that places the drawing view.  Manipulating the camera to a non-standard orientation, may require supplying specific Point objects for eye position & target position, and/or up vector (direction in 3D space that is pointing at the camera), entirely by code can be pretty challenging.  The main thing you have to do is use the DrawingViews.AddBaseView() method, and to be able to specify a custom view orientation & camera, you need to set the 'ViewOrientation' input variable to ViewOrientationTypeEnum.kArbitraryViewOrientation, then supply the camera object to the 'ArbitraryCamera' input variable.  But getting/defining the camera object to use can be a complicated task.

 

Here is a very simplified example iLogic rule for adding a new view to an active drawing document, based on a camera object retrieved from the model document.  The 'home' view in my model document is set to an ISO view of the model, so I am just basically using that (the long way) as the view to capture the camera object from to use in the new view placement line of code.  It doesn't try to manipulate the camera in any special way yet, but shows you some commented out lines of code that you might need to further define to do so.

 

Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oMDoc As Document = ThisDoc.ModelDocument
Dim oSheet As Sheet = oDDoc.ActiveSheet
'position to place the view at (not important for test purposes)(lower left corner of sheet)
Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
Dim oOrientation As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kArbitraryViewOrientation
Dim oStyle As DrawingViewStyleEnum = DrawingViewStyleEnum.kShadedDrawingViewStyle

'create/use a process here to get/define the Camera object needed
Dim oArbCamara As Camera
'oMDoc.Activate
Dim oView As Inventor.View = oMDoc.Views.Add
'oView.Activate
oView.DisplayMode = DisplayModeEnum.kShadedRendering

'orients the view to where your view cube's 'home' orientation is for simplicity here
oView.GoHome 
oView.Fit
'oView.Camera.SceneObject = 'you can specify the contents of the view
'oView.Camera.Target = 'expecting a Point object - position that observer is looking at
'oView.Camera.Eye = 'expecting a Point object - position of observer's eye
'oView.Camera.UpVector = 'direction of 'up' for the observer (perpendicular to line of sight) 
oView.Camera.Fit
oView.Camera.Apply
'oView.Camera.ComputeWithMouseInput(oFromPoint2d, oToPoint2d, oWheelDeltaInteger, ViewOperationTypeEnum.kRotateViewOperation)
oArbCamara = oView.Camera
're-activate the drawing document
'because messing with the view and camera in the model, leaves the model active
oDDoc.Activate

'now create the view
oSheet.DrawingViews.AddBaseView(oMDoc, oPosition, 1.25, oOrientation, oStyle, , oArbCamara)

 

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)