Can't Change Camera Properties

Can't Change Camera Properties

jmfowler1996
Advocate Advocate
783 Views
2 Replies
Message 1 of 3

Can't Change Camera Properties

jmfowler1996
Advocate
Advocate

Hi.

 

I'm really struggling trying to work with cameras.

My end goal is to create a drawing view with a specific orientation.

My problem is that after creating a camera object, when I try to change its properties I am met with an "unspecified error".

 

I have narrowed down the problem to this small piece of code:

' Create a camera to be used to define the view orientation. 
Dim cam As Camera
cam = ThisApplication.TransientObjects.CreateCamera

' Set up the camera. 
cam.Perspective = True
cam.ViewOrientationType = kIsoTopRightViewOrientation

msgbox("Success!")

neither the perspective nor the view orientation type modification works. This is regardless of whether the rule is run from an assembly, a part, or a drawing.

 

I got this code from here, and although it is old code, I can't see any reason why this part would no longer work.

 

I think this is linked to the same issue but when I try to change properties such as the up vector like this:

cam.UpVector = ThisApplication.TransientGeometry.CreateUnitVector(0, 0, 1)

It makes no change to the camera at all, although it doesn't raise an error either.

 

Any help is really appreciated as I've tried so many things and so far no luck and I've run out of ideas.

Cheers.

0 Likes
Accepted solutions (1)
784 Views
2 Replies
Replies (2)
Message 2 of 3

YuhanZhang
Autodesk
Autodesk
Accepted solution

Here is a sample iLogic code for it, change the part document file path then run it:

 

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Open("C:\Part1.ipt",False)

Dim cam As Camera
cam = ThisApplication.TransientObjects.CreateCamera
cam.SceneObject = oPartDoc.ComponentDefinition

' Set up the camera.
cam.Perspective = True  
cam.ViewOrientationType = kIsoTopRightViewOrientation

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

Dim oView As DrawingView
oView = oSheet.DrawingViews.AddBaseView(oPartDoc,ThisApplication.TransientGeometry.CreatePoint2d(25,25),1,ViewOrientationTypeEnum.kArbitraryViewOrientation,DrawingViewStyleEnum.kShadedDrawingViewStyle ,,cam)

MsgBox("Success!")

Hope it 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
Message 3 of 3

jmfowler1996
Advocate
Advocate

Thank you very much.

That was really helpful for me.

0 Likes