Drawing - Aligning base view with largest face landscape

Drawing - Aligning base view with largest face landscape

NachoShaw
Advisor Advisor
733 Views
4 Replies
Message 1 of 5

Drawing - Aligning base view with largest face landscape

NachoShaw
Advisor
Advisor

Hi

 

a while ago i wrote a method for positioning parts into my drawing that forces the base view to show the largest face and then also orients it so that its always landscape. It works well but its slow. The reason for that is the process it goes through which is-

 

open part visible (only works visible)

loop through the part faces checking the area and storing the value

adding the face to a selection set only if the face is larger

once the larger face is selected, use the Look At command to bring that face to the camera

add the base view as Current View

 

i believe it would be much faster if the opening visible process was removed but then how could i reorient the view? is it possible to do this with a matrix of some sort to get the largest face and orient it as the base view?

 

 

Thanks

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
734 Views
4 Replies
Replies (4)
Message 2 of 5

HideoYamada
Advisor
Advisor

Hi,

 


@NachoShaw wrote:

i believe it would be much faster if the opening visible process was removed but then how could i reorient the view? is it possible to do this with a matrix of some sort to get the largest face and orient it as the base view?

Does DrawingView.Camera Property help you?

I have never used Camera APIs, but I feel it is possible.

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 3 of 5

HideoYamada
Advisor
Advisor

I did quick hack, but could not make change to the DrawingView.Camera.

All of the changes to the eye point that my code did were ignored.

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 4 of 5

HideoYamada
Advisor
Advisor

Hello,

 

This is not a complete solution for you, but I found the way to change a DrawingView orientation and report now.

(And I hope this code helping you.)

Option Explicit

Sub FlipCameraToOppositeView()
    Dim oDrawingDoc As DrawingDocument
    Set oDrawingDoc = ThisApplication.ActiveDocument
    
    Dim oSourceView As DrawingView
    Set oSourceView = oDrawingDoc.ActiveSheet.DrawingViews(1)
    
    Dim oCamera As Camera
    Set oCamera = oSourceView.Camera
    Dim oUpVector As UnitVector
    Set oUpVector = oCamera.UpVector
    
    oCamera.Eye = GetOppositeEyePoint(oCamera)
    oCamera.UpVector = oUpVector
    oCamera.ApplyWithoutTransition
End Sub

Function GetOppositeEyePoint(oCamera As Camera) As Point
    Dim X As Double
    Dim Y As Double
    Dim Z As Double

    X = oCamera.Target.X * 2 - oCamera.Eye.X
    Y = oCamera.Target.Y * 2 - oCamera.Eye.Y
    Z = oCamera.Target.Z * 2 - oCamera.Eye.Z
    
    Set GetOppositeEyePoint = ThisApplication.TransientGeometry.CreatePoint(X, Y, Z)
End Function

This code moves the eye point to the opposite side of the target point.

Overwriting the X, Y, Z of Camera.Eye directly will be ignored as I wrote in my last post, but overwriting Eye of Camera is valid.

invalid : oCamera.Eye.X = value

valid : oCamera.Eye = oPoint

 

=====

Freeradical

 Hideo Yamada

 

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp
0 Likes
Message 5 of 5

NachoShaw
Advisor
Advisor

Hi

Appreciate the time in helping me out, looks good and i will try this my project later today. It looks like i might be able to manipulate this to another feature i have been trying to work out which is

 

Getting the current camera from a view and applying the same view to other views as we typically have different variations of parts / assemblies but need the view direction to be the same 🙂

 

 

Thanks again

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes