Get direction of projected view relative to base view

Get direction of projected view relative to base view

wayne.helleyY67EK
Enthusiast Enthusiast
492 Views
3 Replies
Message 1 of 4

Get direction of projected view relative to base view

wayne.helleyY67EK
Enthusiast
Enthusiast

I'm trying to find API functionality that will help me figure out the orientation/direction of projected views relative to the base view.

 

waynehelleyY67EK_0-1699457804439.png

 

Ideally,  don't want to use the co-ordinates of each view incase a user has rearranged the views to no longer follow the angle (1st or 3rd) angle projection.

 

I know that I can use DrawingViewTypeEnum to differentiate which views are projected views but I can't figure out a way to know which direction the views have bene projected in.

 

 

Accepted solutions (1)
493 Views
3 Replies
Replies (3)
Message 2 of 4

bradeneuropeArthur
Mentor
Mentor

Is this what you need:

Dim d As DrawingDocument = ThisDrawing.Document
Dim ds As Sheet = d.ActiveSheet
Dim s As SelectSet = d.SelectSet
Dim dv As DrawingView = s.Item(1)'ds.DrawingViews.Item(4)
MsgBox("view orientation from base: " & dv.ViewOrientationFromBase)
MsgBox( dv.ViewStyle =DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
MsgBox (dv.ViewType = DrawingViewTypeEnum.kProjectedDrawingViewType)

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 4

JelteDeJong
Mentor
Mentor

You could also use the camera to find the direction vector of each view. something like this:

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet

For Each view As DrawingView In sheet.DrawingViews
	Dim camera = view.Camera
	Dim direction = camera.Eye.VectorTo(camera.Target).AsUnitVector()

	logger.Info(String.Format("{0}| X:{1} Y:{2} Z:{3}", view.Name,
				Math.Round(direction.X), Math.Round(direction.Y), Math.Round(direction.Z)))
Next

I get this

JelteDeJong_0-1699480786363.png

 

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 4

waynehelley
Collaborator
Collaborator
Accepted solution
 
Thankyou both for replies.
 
Unfortunately 'ViewOrientationFromBase' from base just returns a boolean value whereas I want to know how the view is orientated relative to the base.
 
JelteDeJong, the camera vector method is a good starting point.  I realized that I would also need to know the angle or the camera. This will be very complicated to figure out (e.g. if my base view is of the Front face but rotated 90deg clockwise, the view to the right of the base view will be out bottom face. I'm sure that there will be a way to figure this out mathematically but my brain can't process this at this moment in time.)
 
I decided to go with the method of using the view positions...
 
For Each dwgView In ActiveSheet.Sheet.DrawingViews
 
'only look at alligned views so that we ignore isometric and floating section/detail views
If dwgView.Aligned = True
 
If dwgView.ViewType = DrawingViewTypeEnum.kProjectedDrawingViewType Or dwgView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType Then
If Math.Round(dwgView.Position.X) = Math.Round(baseView.Position.X)  Then
If Math.Round(dwgView.Position.Y) > Math.Round(baseView.Position.Y) Then
'top
View(4) = dwgView.Name
Logger.Info("Top View: " & dwgView.Name)
Else
'bottom
View(2) = dwgView.Name
Logger.Info("Bottom View: " & dwgView.Name)
End If
Else If Math.Round(dwgView.Position.X) < Math.Round(baseView.Position.X) Then
'left
View(5) = dwgView.Name
Logger.Info("Left View: " & dwgView.Name)
Else
'right
View(3) = dwgView.Name
Logger.Info("Right View: " & dwgView.Name)
End If
 
End If
 
End If
 
Next
Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes