Moving camera to drawingview

Moving camera to drawingview

Jef_E
Collaborator Collaborator
1,173 Views
5 Replies
Message 1 of 6

Moving camera to drawingview

Jef_E
Collaborator
Collaborator

Hi,

 

I am trying to move the camera to a specific drawing view. But for some reason the camera gives a perspective image..

 

What am I doing wrong? It's my first time working the camera.. 😄

 

        Dim oCamera As Camera = m_inventorApplication.ActiveView.Camera

        oCamera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
        oCamera.Eye = oTG.CreatePoint(oView.Position.X, oView.Position.Y, 0)
        oCamera.Target = oTG.CreatePoint(oView.Position.X, oView.Position.Y, 0)
        oCamera.ApplyWithoutTransition()

 

Not as I expected.PNG



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Accepted solutions (1)
1,174 Views
5 Replies
Replies (5)
Message 2 of 6

MechMachineMan
Advisor
Advisor

"Views" are anything within the graphical window in inventor.

 

Your code is simply accessing THAT view.

 

What you want is to dive into a specific DrawingView and tweak the camera object associated with that DrawingView.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 6

Jef_E
Collaborator
Collaborator

Yes @MechMachineMan And how can I do that? As you see I am failing to do so.

 

I can move my camera object, but it does not stay parallel to my drawing sheet.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 4 of 6

MechMachineMan
Advisor
Advisor

I misunderstood what you are trying to do.

 

However, the issue is that you are setting your eye and target to be the same point, which doesn't logically make sense. It means that the 2 points are exactly the same and the vector between them is undefined/arbitrary.

 

You need to supply a Z value to the eye, as I did below:

 

 

Dim oView As DrawingView
oView = ThisApplication.ActiveDocument.ActiveSheet.DrawingViews(1)

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

Dim oCamera As Camera = ThisApplication.ActiveView.Camera

oCamera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
oCamera.Eye = oTG.CreatePoint(oView.Position.X, oView.Position.Y, oCamera.Eye.Z)
oCamera.Target = oTG.CreatePoint(oView.Position.X, oView.Position.Y, 0)
oCamera.ApplyWithoutTransition()

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 6

Jef_E
Collaborator
Collaborator

@MechMachineMan Cheers!

 

Now one more thing, how can I set the zoom distance? What I want is to zoom that the view rangebox occupies most of the camera. If you get what I mean 🙂

 

Greetings.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 6 of 6

MechMachineMan
Advisor
Advisor
Accepted solution

 

 

 

 

Just like this....

 

Kinda like in this previous post I found asking to do the same thing....

https://forums.autodesk.com/t5/inventor-customization/zoom-to-view-in-drawing/td-p/2655306

 

SyntaxEditor Code Snippet

Dim oView As DrawingView
oView = ThisApplication.ActiveDocument.ActiveSheet.DrawingViews(1)

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

Dim oCamera As Camera = ThisApplication.ActiveView.Camera

oOversizePct = 2
With oCamera
	.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
	.Eye = oTG.CreatePoint(oView.Position.X, oView.Position.Y, .Eye.Z)
	.Target = oTG.CreatePoint(oView.Position.X, oView.Position.Y, 0)
	.SetExtents(oOversizePct * oView.Width, oOversizePct * oView.Height )
	.ApplyWithoutTransition()
End With

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type