Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Simply, I select the view in the drawing then return the "Oxy plane". Please help experts.
Solved! Go to Solution.
Simply, I select the view in the drawing then return the "Oxy plane". Please help experts.
Solved! Go to Solution.
We can inspect the view's camera's properties to determine 'line of sight' (Camera.Eye to Camera.Target) and its 'up vector' (Camera.UpVector), which is perpendicular to the line of sight direction, to get our bearings (orientation) as to which direction we are looking at the model, from the perspective of the model's origin. Then determine which origin WorkPlane that line of sight is parallel with. There is a sample iLogic rule code at the end which you can try out, but it is not ideal. Not sure exactly what type of feedback or results you need to get from the code, so it just returns a String right now, containing either the name of the WorkPlane, or telling you that it was not aligned with any model origin plane.
Unfortunately, there is no direct association between standard views of a model in a drawing, and the orientation of the model's origin. The views in a drawing go by the DrawingView.Camera.ViewOrientationType which has a value from the ViewOrientationTypeEnum. Then that is based on the ViewCube orientation, not the origin geometry of the model. The ViewCube's orientation can be set/changed independently from the model's origin geometry, and can even be set to an orientation that is in no way parallel or aligned with any of the model's origin geometry. So, we must first get/know that (tranformation) association between the model's origin geometry and the ViewCube's orientation. And unfortunately, there is no ViewCube object for us to grab ahold of by code, and inspect. Some people, or entire organizations, may never change the orientation of the ViewCube, and its orientation is the same in all of their Templates, and if that is the case, then that transformation association can be recorded, or hardcoded into your automation codes, because it is 100% predictable and stable. For others, no such luck.
The ViewOrientationTypeEnum does not contain all possible 'square or iso' directions that we can be looking at the model, so sometimes working directly with the Camera is the only way to get the drawing view to look at the model the way we need it to. We can also dictate to the drawing view to use the Camera object of the DesignViewRepresentation that we set that DrawingView to, which can help simplify things.
Sub Main
Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a Drawing View.")
If oView Is Nothing Then Return
Dim sPlaneName As String = GetViewPlane(oView)
MsgBox("That view is looking at the origin WorkPlane named: " & sPlaneName, vbInformation, "iLogic")
End Sub
Function GetViewPlane(DView As Inventor.DrawingView) As String
If DView Is Nothing Then Return String.Empty
Dim oCam As Inventor.Camera = DView.Camera
Dim oLineOfSight As Inventor.Vector = oCam.Eye.VectorTo(oCam.Target)
Dim oUpVect As UnitVector = oCam.UpVector
Dim oModelDoc As Inventor.Document = DView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oCD As ComponentDefinition = oModelDoc.ComponentDefinition
For Each oWPlane As WorkPlane In oCD.WorkPlanes
If oWPlane.Plane.Normal.IsParallelTo(oLineOfSight.AsUnitVector, .001) Then
Return oWPlane.Name
End If
Next
Return "Not Aligned With An Origin WorkPlane"
End Function
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
(Not an Autodesk Employee)
Thank you so much. Very detail explaining.
Without this code the program still runs fine.
Dim oUpVect As UnitVector = oCam.UpVector