Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing the value of section plane through API

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
NemKumar
709 Views, 6 Replies

Changing the value of section plane through API

Hi,

 

I am using Inventor 2015. I have a 3D input device which can replace mouse. When I move the device in space, I get the coordinates in 3D.  I plan to use it for demonstraton of half section view. If I move the device in space, it should move the section plane.

 

I am able to invoke the command "AssemblyHalfSectionViewCmd" , but I dont know how to give the value for the depth of the half section plane.

Is it even possible through API.

 

 I would like to demonstrate the extrusion in the same way. Any ideas how can it be done.

 

Thanks,

6 REPLIES 6
Message 2 of 7
philippe.leefsma
in reply to: NemKumar

You need to use the ClientGraphics API to create temporary section views. There is no way you can control the section created from the UI command, you would need to create your own graphics so you have control over them.

 

Take a look at GraphicsNode.SliceGraphics in the API help files. You can define a transient plane passed as input to the slice method. Using your device, you will be able to create a plane at the required position and modify the graphics.

 

Below is a VBA sample extracted from the help files. You can also take a look at the advanced section of the DevCamp material: in my ClientGraphics material I wrote a C# sample that allows to select a section plane and slice an assembly. The user can also click in the graphic window and the slicing side will be flipped, which illustrates how to update the plane.

 

Public Sub SliceClientGraphics()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument

    ' Set a reference to component definition of the active part.
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oDoc.ComponentDefinition

    Dim bApplyCap As Boolean
    If MsgBox("Do you want an end cap?", _
vbQuestion + vbYesNo, "SliceGraphics") = vbYes Then bApplyCap = True Else bApplyCap = False End If Dim oClientGraphics As ClientGraphics Set oClientGraphics = oCompDef.ClientGraphicsCollection.Add("SliceGraphicsID") ' Create a new graphics node within the client graphics objects. Dim oSurfacesNode As GraphicsNode Set oSurfacesNode = oClientGraphics.AddNode(1) Dim oTransientBRep As TransientBRep Set oTransientBRep = ThisApplication.TransientBRep ' Create a copy of the solid body in the part Dim oBody As SurfaceBody Set oBody = oTransientBRep.Copy(oCompDef.SurfaceBodies.Item(1)) ' Create client graphics based on the transient body Dim oSurfaceGraphics As SurfaceGraphics Set oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody) ' Color it red oSurfacesNode.RenderStyle = oDoc.RenderStyles.Item("Red") ' Make the body in the part invisible oCompDef.SurfaceBodies.Item(1).Visible = False Dim oLineSegment As LineSegment Set oLineSegment = ThisApplication.TransientGeometry.CreateLineSegment( _
oSurfacesNode.RangeBox.MaxPoint, oSurfacesNode.RangeBox.MinPoint) Dim oRootPoint As Point Set oRootPoint = oLineSegment.MidPoint ' Get the negative Z-axis vector Dim oNormal As Vector Set oNormal = ThisApplication.TransientGeometry.CreateVector(0, 0, -1) ' Create a plane normal to Z axis with the root point at the center of part Dim oPlane As Plane Set oPlane = ThisApplication.TransientGeometry.CreatePlane( _
oRootPoint, oNormal) Dim oSlicingPlanes As ObjectCollection Set oSlicingPlanes = ThisApplication.TransientObjects.CreateObjectCollection Call oSlicingPlanes.Add(oPlane) ' Slice the client graphics Call oSurfacesNode.SliceGraphics(bApplyCap, oSlicingPlanes) ' Update the view to see the result ThisApplication.ActiveView.Update End Sub

 

Regards,

Philippe.

 

______________________________________________________________

If my post answers your question, please click the "Accept as Solution"

button. This helps everyone find answers more quickly!

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 7
NemKumar
in reply to: philippe.leefsma

This solution solves my problem to some extent but not fully. I am trying to imitate the section view functionality of Inventor. My device gives 22-15 fps.

With this GraphicsNode.sliceGraphics API, my fps drops to 7-8 fps. I am using nontransacting graphics for drawing the arrow and plane which is updated when my device is moved in space.

 

How can I increase my fps to around 20 fps. Is there any lower level API which can help me imitate section view for my device.

 

Urgent help needed.

 

Thanks in Advance

Message 4 of 7
philippe.leefsma
in reply to: NemKumar

There is no lower level API. Because the API is COM-wrapped, there is some overhead, so it is unlikely you will be able to reach the same fps than Inventor itself. Performances may also depends on how your ClientGraphics code is structured. As a general advice, you should try to create as few Inventor API objects as possible, as each COM object will cause overhead. Transient graphics should provide the best possible performances from the API.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 7
NemKumar
in reply to: philippe.leefsma

Thanks for your reply,

 

How can i change the default behaviour of mouse in section view. Currently I have to drag the red arrow to move the section plane I want to be able to do it by mouse scrolling . I know there are some settings for keys used in rotation., pan etc. which can be changed. 

 

Can I set the section plane movement on mouse scrolling. This can also help me in what I am trying to achieve.

Message 6 of 7
philippe.leefsma
in reply to: NemKumar

I don't see a way to achieve that. You are talking about a UI feature that does not expose any API to control its behavior, this is different than setting keys for the standard mouse actions. In the section plane, the red arrow is a client graphics that needs to be selected in order to modify the plane position.

 

Sorry for the bad news,

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 7 of 7

Hello together,

 

now it works (I tested it in Inv 2018, but should work in 2017 too).

See the following post

Create/Modify Design Views in ipt

 

Best Regards

Wolfgang

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report