Mimic/trigger Viewcube behavior programatically.

Mimic/trigger Viewcube behavior programatically.

ktucker86UDQ
Participant Participant
487 Views
5 Replies
Message 1 of 6

Mimic/trigger Viewcube behavior programatically.

ktucker86UDQ
Participant
Participant

What coordinate basis does the View Cube use? I attempt to set my Camera.Eye along the X, Y, or Z axes (using transientgeometry), but the part never appears to be perfectly centered. What coordinates does the ViewCube use to manipulate the camera into the 6 face views?

0 Likes
488 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

The orientation of the view cube itself can be set/changed to different orientations in relation to the main model coordinate system.  So if you are looking straight on at the 'Front' face of the view cube, that may not necessarily mean a specific (set in stone) orientation of the origin planes and origin axes.  You have to be familiar with how the view cube is oriented in relation to your origin planes/axes, and try to keep it consistent throughout all your designs.

 

Edit:  In a 'New' part document, which is created from a default part template that was installed by Autodesk, when you are looking straight at the 'Front' face of the view cube, and the 'Top' face is above that, then the main model coordinate system has its Z-Axis pointing straight out of your screen at you, and the X-Axis is pointing to the right, and the Y-Axis is pointing up (towards the top of your screen).  But you can set different faces of the view cube as Front or Top, or 'reset front', so that orientation is user changeable, per model document.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

ktucker86UDQ
Participant
Participant

I guess, after reflecting further, what I am looking for is the ability to "Flip" a section view. Whenever I create a section view via program, its consistently on the same side of the selected axis. If I do it via the interface and click on a plane, the section view will be on the side of my camera. Can anyone assist? If there was a way to call the function behind Right Click -> Flip Section that would be super!.

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

Hi @ktucker86UDQ.  I am not sure that we have the ability to flip the direction of a section view in a model document using normal iLogic or Inventor API code, but we can definitely create them and modify them in other ways.  When they are created by code, the 'Normal' (a UnitVector indicating natural direction) of the plane is used to indicate which side of the plane will be removed.  You can check the Normal of the plane before you use them to create a section view, and can inspect the normal of the retrieved planes when inspecting an already existing section view.  The SectionDrawingView object in a drawing does have a ReverseDirection method (among others) allowing you more control over it.  But during my investigation, I did manage to create a simple iLogic rule that will reverse the direction of an existing section view in a part document.  This code mainly uses the same commands that are used in the user interface tools to make things happen, so this is less ideal than using API code for the same task.  It expects that the 'active' DVR (DesignViewRepresentation) is the one with the section view stored in it that we want to target, but you could likely just activate the one you want to work on instead if you wanted.  Here it is anyways.

Dim oPDoc As PartDocument = ThisDoc.Document
Dim oDVR As DesignViewRepresentation = oPDoc.ComponentDefinition.RepresentationsManager.ActiveDesignViewRepresentation
oPDoc.SelectSet.Clear
oPDoc.SelectSet.Select(oDVR)
Dim oCDs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions
Dim EditSectionView As ControlDefinition = oCDs.Item("DesignViewEditSectionCmd")
Dim FlipSectionDir As ControlDefinition = oCDs.Item("flipSectionDir")
Dim Done As ControlDefinition = oCDs.Item("AppContextual_DoneCmd")
EditSectionView.Execute2(False)
FlipSectionDir.Execute2(False)
Done.Execute2(False)

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

ktucker86UDQ
Participant
Participant

Thanks, I think youve pointed me in the right direction, but still am failing to flip a section view on an .ipt or .iam. I can, each time I want to, create a section view on the XY, XZ, or YZ planes, but they always face the same way. Trying to use flipNormal on a workplane seems like it might suit my needs, but the program errors out on this function call consistently.

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

Hi @ktucker86UDQ.  I do not know if you are familiar with TransientGeometry or not, but since all you seem to need as input for the DesignViewRepresentation.SetSectionView method is the section view type and one or two Plane objects, you may be able to create your own new transient Plane object, so that you can specify its 'direction', then use that in the method.  If the section view already exists, you could use the DesignViewRepresentation.GetSectionViewInfo Method  to get the existing Plane that it is based on.  Then use the data from that existing Plane(s) to define the new Plane, but reverse the 'Normal' (UnitVector).  Just some additional thoughts, but I have not had time to test this yet.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes