Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
jdasilvaS39UQ
160 Views, 1 Reply

Client Graphics on drawing, position based on part location within view

Hi, I am trying to highlight components on a drawing view as solid red using client graphics. I am using the componentoccurrence of the assembly in the drawing view to create surfacegraphics and display that. It is working where it will display what i was expecting but I am stuck trying to position it, it defaults to the center of the view. I can move it with SetTransformBehavior but I can't get an accurate position based on the part itself.

 

So my question is how do we get the part origin point in drawing/drawing view space using a componentoccurrence

 

This loops through each view

For Each oDrawingView In sparesSheet.DrawingViews
		Try
			oDataSets = oDrawingView.GraphicsDataSetsCollection.Item("CG_Test3")
			oDataSets.Delete
			oDataSets = oDrawingView.GraphicsDataSetsCollection.Add("CG_Test3")
		Catch
			oDataSets = oDrawingView.GraphicsDataSetsCollection.Add("CG_Test3")
		End Try
		
		Try
			oClientGraphics = oDrawingView.ClientGraphicsCollection.Item("CG_Test3")
			oClientGraphics.Delete
			oClientGraphics = oDrawingView.ClientGraphicsCollection.Add("CG_Test3")
		Catch
			oClientGraphics = oDrawingView.ClientGraphicsCollection.Add("CG_Test3")
		End Try
		
		Dim oModelDoc As Document
		oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
		
		TraverseAssembly(oModelDoc.ComponentDefinition.Occurrences)
		
		iLogicVb.UpdateWhenDone = True	
	Next

 

 

Here is the part actually creating client graphics within the traverseassembly loop

			Dim oLineNode As GraphicsNode
			oLineNode = oClientGraphics.AddNode(1)
			       
			Dim oTransientBRep As TransientBRep
			oTransientBRep = ThisApplication.TransientBRep
			       
			 'By Transient Brep Class To copy the surface body
			  Dim oBody As SurfaceBody
			  oBody = oTransientBRep.Copy(oOcc.Definition.SurfaceBodies.Item(1))
			    
			  ' Create client graphics based on the transient body
			  Dim oSurfaceGraphics As SurfaceGraphics
			  oSurfaceGraphics = oLineNode.AddSurfaceGraphics(oBody)
				
				oSurfaceGraphics.Color = oColor
				
				oSurfaceGraphics.BurnThrough = True
				
				'oSurfaceGraphics.SetViewSpaceAnchor(oTG.CreatePoint(0,0,0), oTG.CreatePoint2d(10,10), ViewLayoutEnum.kBottomLeftViewCorner)
				Dim temp As WorkPoint
				temp = oOcc.Definition.WorkPoints(1)
				
				Dim tempproxy As WorkPointProxy
				oOcc.CreateGeometryProxy(temp, tempproxy)
				
				oSurfaceGraphics.SetTransformBehavior(oTg.CreatePoint(tempproxy.Point.X, tempproxy.Point.Y, tempproxy.Point.Z), DisplayTransformBehaviorEnum.kFrontFacing)