Get / Set Camera view

Get / Set Camera view

NachoShaw
Advisor Advisor
636 Views
1 Reply
Message 1 of 2

Get / Set Camera view

NachoShaw
Advisor
Advisor

Hi

 

i am looking for a piece of code that ca nhelp me achieve my task which is:

 

add a drawing view (manually for now)

use the custom view to rotate the model to a specific view

run some code to get the camera view from the drawing view and apply that view to all other views in a drawing sheet.

 

I have a bunch of different parts all on one sheet like a brochure and i need all of the views to have the exact same camera view. its very difficult to do manually....

 

is it possible to get a camera view and apply it to another 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
637 Views
1 Reply
Reply (1)
Message 2 of 2

YuhanZhang
Autodesk
Autodesk

Here is a VBA sample, you should have a drawing view placed on the first sheet in a drawing, also you should change the file path in the code for oModel:

 

Sub test()
    Dim oDrawing As DrawingDocument
    Set oDrawing = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDrawing.Sheets(1)
    
    Dim oDrawingView As DrawingView
    Set oDrawingView = oSheet.DrawingViews(1)
    
    Dim oCamera As Camera
    Set oCamera = oDrawingView.Camera
    
    Dim oModel As Document
    Set oModel = ThisApplication.Documents.Open("C:\Temp\Part1.ipt", False)
    
    Dim oNewBase As DrawingView
    Set oNewBase = oSheet.DrawingViews.AddBaseView(oModel, oDrawingView.Center, 1, kArbitraryViewOrientation, kShadedDrawingViewStyle, , oCamera)
    
    Dim oPt As Point2d
    Dim dHeight As Double
    dHeight = oDrawingView.Center.Y / 2 + oNewBase.Center.Y / 2
    
    Set oPt = ThisApplication.TransientGeometry.CreatePoint2d(oDrawingView.Center.X, oDrawingView.Center.Y + dHeight)
    oNewBase.Center = oPt
End Sub

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes