make the client graphics always visible even if they are blocked by other objects

By Xiaodong Liang

Issue
I would like to create a similar preview as the Inventor does (for example when extruding text with a green arrow). With my function, I can create this arrow but when the direction is negative or symmetric, the part of the arrow toward the material is not visible (obstructed by the material). Do I have to set temporarely the material as transparent or is there a different way to do it?

Solution
You just need to set BurnThrough property of the GraphicsPrimitive ( e.g TriangleStripGraphics) to True, thus the graphics are always visible even if they are blocked by other objects.  

The code below assumes a part with a body is opened. It copies the body to a new body. It adds each face of the new body to a surface graphics , highlights it. Since the surface graphics’ BurnThrough is True, it is visible even there is any other faces locate ahead of it.

Public Sub Test()                 Dim partDoc As PartDocument          partDoc = m_inventorApp.ActiveDocument                  Dim cg As ClientGraphics          Try              cg = partDoc.ComponentDefinition.ClientGraphicsCollection.Item("test")              cg.Delete()          Catch ex As Exception          End Try                 cg = partDoc.ComponentDefinition.ClientGraphicsCollection.Add("test")          Dim body As SurfaceBody          body = partDoc.ComponentDefinition.SurfaceBodies.Item(1)                 Dim newBody As SurfaceBody          newBody = body.AlternateBody(SurfaceGeometryFormEnum.SurfaceGeometryForm_NURBS)                 Dim hs As HighlightSet          hs = partDoc.CreateHighlightSet                 Dim node As GraphicsNode          node = cg.AddNode(1)                 Dim trans As Matrix          trans = node.Transformation          trans.Cell(1, 4) = trans.Cell(1, 4) + (body.RangeBox.MaxPoint.X - body.RangeBox.MinPoint.X) + 2          node.Transformation = trans                 Dim f As Face          Dim surfGraphics As SurfaceGraphics          For Each f In newBody.Faces              Dim newFace As Face              newFace = body.BindTransientKeyToObject(f.TransientKey)                     surfGraphics = node.AddSurfaceGraphics(f)              surfGraphics.Color = m_inventorApp.TransientObjects.CreateColor(255, 0, 0)              surfGraphics.BurnThrough = True                     Call hs.AddItem(newFace)                     If MsgBox("Continue?", vbYesNo, "Alternate Body Mapping Test") = vbNo Then                  hs.Clear()                  cg.Delete()                  Exit Sub              End If                     hs.Clear()                     surfGraphics.Color = m_inventorApp.TransientObjects.CreateColor(100, 100, 100)              surfGraphics.BurnThrough = False           Next                 cg.Delete()      End Sub
<p style="margin: 0px"><span style="line-height: 140%;color: blue"></span></p> </div>

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading