Place a saved camera view in a drawing using I logic

Place a saved camera view in a drawing using I logic

chris_davis
Contributor Contributor
257 Views
4 Replies
Message 1 of 5

Place a saved camera view in a drawing using I logic

chris_davis
Contributor
Contributor

I have saved some camera view in an assembly. I now want to place a view on a drawing using one of these saved views. 

chris_davis_0-1746479811705.png

I can get the standard views that i-logic allows you to access to work but cant figure out how to access these saved view.  here is what I would expect the code to be like, with  oCamera being a the saved camera view.

chris_davis_1-1746479985911.png

 

 

 Thanks for the help.

0 Likes
Accepted solutions (1)
258 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @chris_davis.  Specifying the Camera object when using the DrawingViews.AddBaseView method is only allowed/used when you specified kArbitraryViewOrientation for the ViewOrientation.  Specifying the kSavedCameraViewOrientation variation is the way to go, but it may need to be done after the view has been placed, or you may need to include the 'last' optional input it is asking for named 'AdditionalOptions', which is a NameValueMap, in which you specify the name of that specific design view representation, and optionally whether or not it is 'associative', among other possible options.  If not including the 'AdditionalOptions', then you will need to edit the view after that line of code, to set the view's view representation (DrawingView.SetDesignViewRepresentation), then set its view orientation to that view representation's saved camera.

oCam = DrawingView.Camera

oCam.ViewOrientationType = kSavedCameraViewOrientation

oCam.Fit

oCam.Apply

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

chris_davis
Contributor
Contributor

Wesley @WCrihfield

Thank you for the response. I'm not understanding. Below is what I did and it gives me the attached error.  I'm not really a programmer so I'm struggling my way through this. The Idea is that using i-logic I can pick the view that best shows what I want and that view is to be placed on the drawing. Inventor gives me the front, back, left, right, etc. (.kTopViewOrientation, .kRightViewOrientation, .kLeftViewOrientation)

that I can place. I have no problem getting these to place on a drawing using i-logic. However, in some cases I want the front right, front Left 

chris_davis_3-1746564530958.png and I have not found a way to get these views. So that is why I created the camera views under representations.

chris_davis_4-1746564942748.png

 

chris_davis_1-1746564220679.png

 

Thanks,

Chris Davis

 

 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

If doing this manually, there are a couple different ways you could do it.

1)

  1. Edit the view, which shows the Drawing View dialog, then set the 'Design View' to the one you want to use.
  2. Click the 'gear' icon next to that Design View drop-down control.
  3. In the 'View Representation Options' dialog, check the checkbox beside the option named 'Camera View'.
    1. That tells it that you want this drawing view to use the Design View's own saved Camera.
    2. This option may only be available for ' base' views, and not for 'projected' views, or other views which have a parent view.
    3. The ViewOrientationTypeEnum.kSavedCameraViewOrientation variation of the ViewOrientationTypeEnum is essentially for specifying that option, but only when a valid design view was specified (not the 'Master' or '[Primary]' one), and only when it is a base view.

WCrihfield_0-1746616963654.png

2)

  1. When you initiate the manual tool or command to create a new 'base' view, but before you have 'placed' an instance of the view on the sheet, you will usually see the 'ViewCube' showing near the upper, right corner of preview of the view's graphics.  When you see that, click on the small drop-down arrow near the bottom right corner of that ViewCube.
  2. In that context menu, choose the option named "Custom View Orientation".
    1. WCrihfield_2-1746617666947.png
  3. When you do, that will essentially put you into a special, very limited environment, with just a few tools available, all having to do with controlling how you are viewing that model.  You can use the usual 'ViewCube' behavior here, but you can also control orbit type rotations, and controlled rotations, 'Look At' functionality, (ortho, perspective, ortho with perspective), and more.
  4. Set things up how you want them, then click the 'Finish Custom View' button in the ribbon to return back to the normal drawing environment.
  5. The following screen capture is of the ribbon while in that special environment / mode.

WCrihfield_1-1746617614898.png

Now, on the coding side, the section of code I posted would go after your other line of code which places the view.  Then the first line of code that I posted would be getting the Camera object from the DrawingView object that you just placed an instance of, using that variable you used there (oPlanView) which is then representing that view (instead of just the 'DrawingView' Type specifier that was in my code example).  So, you would effectively be getting the Camera from the drawing view object that you just placed, then modifying the properties of that camera, which in turn effects what you see within the drawing view.

The other coding related thing I mentioned earlier was to just specify the first 5 inputs for that DrawingViews.AddBaseView method, without specifying a design view, or anything further than that.  Then after that line of code, when the view has already been created & placed, using that oPlanView variable, which now represents that newly created view, use its SetDesignViewRepresentation method to set which design view you want that view set to, and specify if it should be 'Associative'.  Then, in another line of code below that one, get that view's camera, and set those property values, so that the drawing view will be using that design view's own camera (as mentioned earlier)...if possible, due to the restrictions mentioned.

I can't provide a whole, usable code example, because so far you have only supplied images of a small portion of your code, not the actual editable text of the whole rule.  You can post your whole rule in the forum by one of two main ways.

  • Use the built-in tool named "Insert/Edit code sample", which has an icon which looks like "</>", right in the forum reply tools, which creates a 'code window' for you to paste your code directly into.
  • WCrihfield_4-1746619376014.png
  • Or just copy & paste your code into a new text file, save it to your 'Temp' folder, then attach it to your forum post/reply.

WCrihfield_5-1746619416387.png

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

chris_davis
Contributor
Contributor

Wesley @WCrihfield,

Thank you for the help. I was able to get my code to work. Attached is the order I placed the code to get it to run. I hope this will help others how are thing to do something similar.

Line 35 Places the view, (Step 1)

Then 41 Sets the view to "Front Right View" (Step 2)

Then 43 says its the camera view. (Step 3)

 

This follows the steps you showed in your response if doing it manually.

For some reason the oCam.Fit was giving me trouble, but it worked when I commented it out.

 

chris_davis_0-1746627029274.png

Thanks Again!

Chris Davis

 

0 Likes