Requesting Example: TransientBRep.CreateSilhouetteCurve Method

Requesting Example: TransientBRep.CreateSilhouetteCurve Method

J-Camper
Advisor Advisor
434 Views
14 Replies
Message 1 of 15

Requesting Example: TransientBRep.CreateSilhouetteCurve Method

J-Camper
Advisor
Advisor

Does anyone have a working example of this Method:

 

TransientBRep.CreateSilhouetteCurve Method

I'm trying to capture the overall outside profile of a solidbody, viewed from a particular direction.  I was hoping to keep everything transient and this looked like the right method, but I can't get any results from it.  It always returns nothing with my tests.

I want to know if anyone is willing to share an example for how to use this, or if you have any other suggestions for capturing the overall profile of a solid view from a direction, I'm open to trying a different route.

0 Likes
435 Views
14 Replies
Replies (14)
Message 2 of 15

Stakin
Collaborator
Collaborator

TransientBRep.CreateSilhouetteCurve( Face As Face, ViewDirection As UnitVector, ReturnCoincidentSilhouettes As Boolean )

I tested ,maybe two reason

1.if silhouette curves that are coincident to the edges of the face are not be returned,regardless of whether this parameter "ReturnCoincidentSilhouettes" is true or false.

2.maybe. the plane face didn’t return.

 

 

maybe it is a bug,you can try again.

 

by the way,in the help description,it indicats

This method can return Nothing in the case where there is not a silhouette curve for the specified face.

 

 

0 Likes
Message 3 of 15

J-Camper
Advisor
Advisor

yeah i believe i am just getting the nothing result mentioned in the help.  I just haven't found a face where this results and anything, so i wanted to see if anyone has an example of this method actually producing results.

It might just be that I'm trying to use it for something it isn't meant to do, but I can't figure out what it is meant to do.

0 Likes
Message 4 of 15

Stakin
Collaborator
Collaborator

you can make a cylinder face to test.

0 Likes
Message 5 of 15

J-Camper
Advisor
Advisor

i see. this is not going to work for me since it doesn't work with all face types.

0 Likes
Message 6 of 15

Stakin
Collaborator
Collaborator

 

Try this,the wireline is  Silhouette created by tansientbrep, the Sketchline is created by sketch3d Silhouette.

Sub main
	oInvApp = ThisApplication
	Dim oDoc As PartDocument = oCreateTempIPT()
	Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim oName As String = "Silhouette"
	Dim oViewDirection As UnitVector 
	oViewDirection= oInvApp.TransientGeometry.CreateUnitVector(1, 1, 1)
	oCreateClientFeature(oDef, oName, oViewDirection)
	oDoc.Close(True)
End Sub
Function oCreateTempIPT() As PartDocument
	Dim oDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, , False)
	Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim oSk As PlanarSketch
	Dim oTG As TransientGeometry = oInvApp.TransientGeometry
	oSk = oDef.Sketches.Add(oDef.WorkPlanes.Item(3))
	oSk.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(0, 0), 10)
	oSk.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(5, 0), 3)
	Dim oProfile As Profile
	oProfile = oSk.Profiles.AddForSolid
	Dim oExtrudeDef As ExtrudeDefinition
	oExtrudeDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
	oExtrudeDef.SetDistanceExtent(12, kSymmetricExtentDirection)
	Dim oExtrude As ExtrudeFeature
	oExtrude = oDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
	Dim oExtrude1 As ExtrudeFeature
	Dim oArc(1) As SketchArc
	Dim i2 As Integer = 0
	For i2 = 0 To 1
		oSk = oDef.Sketches.Add(oExtrude.EndFaces(1))
		If i2 = 1 Then
			oSk.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(0, -5), 2)
		Else
			oSk.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(-7, -2), oTG.CreatePoint2d(-3, 2))
		End If
		oProfile = oSk.Profiles.AddForSolid
		oExtrudeDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kNewBodyOperation)
		oExtrudeDef.SetDistanceExtent(5, kPositiveExtentDirection)
		oExtrude1 = oDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
		oSk = oDef.Sketches.Add(oDef.WorkPlanes.Item(2))
		oSk.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(40, 70 + i2 * 90), 8)
		oSk.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(40, 70 + i2 * 90), 3)
		Dim oRevolve As RevolveFeature
		oProfile = oSk.Profiles.AddForSolid
		oRevolve = oDef.Features.RevolveFeatures.AddByAngle(oProfile, oDef.WorkAxes.Item(3), 8 * PI / 5 + 2 * PI / 5 * i2, kSymmetricExtentDirection, kNewBodyOperation)
		oSk = oDef.Sketches.Add(oDef.WorkPlanes.Item(2))
		oArc(0) = oSk.SketchArcs.AddByCenterStartSweepAngle(oTG.CreatePoint2d(0, 70 + i2 * 90), 12, -PI / 2, PI)
		oArc(1) = oSk.SketchArcs.AddByCenterStartSweepAngle(oTG.CreatePoint2d(0, 70 + i2 * 90), 2, -PI / 2, PI)
		oSk.SketchLines.AddByTwoPoints(oArc(0).StartSketchPoint, oArc(1).StartSketchPoint)
		oSk.SketchLines.AddByTwoPoints(oArc(0).EndSketchPoint, oArc(1).EndSketchPoint)
		oProfile = oSk.Profiles.AddForSolid
		oRevolve = oDef.Features.RevolveFeatures.AddByAngle(oProfile, oDef.WorkAxes.Item(3), 3 * PI / 2 + i2 * PI / 2, kSymmetricExtentDirection, kNewBodyOperation)
	Next
	Return oDoc
End Function
Function oCreateClientFeature(oSourceDef As PartComponentDefinition, oInName As String, oViewDir As UnitVector)
	Dim oName As String
	Dim oDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject)
	Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
	oName = "BRep-" & oInName & "-White Line"
	Dim oCfDef As ClientFeatureDefinition = oCompDef.Features.ClientFeatures.CreateDefinition()
	Dim oCf As ClientFeature = oCompDef.Features.ClientFeatures.Add(oCfDef, "[" & oName & "]")
	oCf.Name = "[" & oName & "]"
	oCfDef = oCf.Definition
	Dim oClientGraphics As ClientGraphics = oCfDef.ClientGraphicsCollection.Add(oName)
	Dim oBody As SurfaceBody
	Dim oFace As Face
	Dim oSurfacesNode As GraphicsNode = oClientGraphics.AddNode(1)
	oSurfacesNode.AllowSlicing = True
	oSurfacesNode.AllowSliceCapping = True
	For Each oBody In oSourceDef.SurfaceBodies
		Dim oTransientBRep As TransientBRep = oInvApp.TransientBRep
		Dim oSurfacebody As SurfaceBody
		For Each oFace In oBody.Faces
			oSurfacebody = oTransientBRep.CreateSilhouetteCurve(oFace, oViewDir, True)
			If oSurfacebody Is Nothing Then Continue For
			oSurfacesNode.AddSurfaceGraphics(oSurfacebody)
		Next
		Dim oFeatureDef As NonParametricBaseFeatureDefinition = oCompDef.Features.NonParametricBaseFeatures.CreateDefinition
		Dim oCollection As ObjectCollection = oInvApp.TransientObjects.CreateObjectCollection
		oCollection.Add(oBody)
		oFeatureDef.BRepEntities = oCollection
		oFeatureDef.OutputType = BaseFeatureOutputTypeEnum.kSurfaceOutputType
		Dim oBaseFeature As NonParametricBaseFeature = oCompDef.Features.NonParametricBaseFeatures.AddByDefinition(oFeatureDef)
	Next
	Dim oSk3D As Sketch3D = oCompDef.Sketches3D.Add
	oSk3D.Name = "Sketch3D-" & oInName 
	Dim oWax As WorkAxis = oCompDef.WorkAxes.AddFixed(oCompDef.WorkPoints.Item(1).Point, oViewDir, True)
	Dim oSilho As SilhouetteCurve
	Dim oWkSFace As WorkSurface
	For Each oWkSFace In oCompDef.WorkSurfaces
		oSilho = oSk3D.SilhouetteCurves.AddSilhouette(oWkSFace.SurfaceBodies.Item(1), oWax)
	Next
	Dim oCam As Camera
	oCam = oInvApp.ActiveView.Camera
	oCam.ViewOrientationType = kIsoTopRightViewOrientation
	ocam.Fit()
	oCam.Apply()
End Function
Public Shared oInvApp As Inventor.Application

0 Likes
Message 7 of 15

J-Camper
Advisor
Advisor

That's close to what I want, but still not really.  The Silhouette projections seam to be created on the center of the part, so parts with machining along the centerline will not get captured correctly. 

I have attached a test part showing the limitations, I modified the code you provided to create projection from the part instead of making a new part.

0 Likes
Message 8 of 15

Stakin
Collaborator
Collaborator

Maybe use Drawingview can meet your demand

Try below snippet.

note:it cann't involve a revolved surface silhouette

Option Explicit on
Sub main
	oInvApp = ThisApplication
	Dim oDoc As PartDocument = oInvApp.ActiveDocument
	Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim oName As String = "Silhouette"
	oCreateClientFeature(oDef, oName, oInvApp.ActiveView.Camera)
End Sub

Function oCreateClientFeature(oCompDef As PartComponentDefinition, oInName As String, viewCam As Camera)
	Dim oViewDir As UnitVector = viewCam.Eye.VectorTo(viewCam.Target).AsUnitVector
	Dim oName As String = "Sketch-" & oInName
	Dim xAxis As UnitVector = viewCam.UpVector.Copy
	Dim UpPoint As Point = viewCam.Eye.Copy
	UpPoint.TranslateBy(xAxis.AsVector)
	Dim EyeTargetUpPlane As Plane = oInvApp.TransientGeometry.CreatePlaneByThreePoints(viewCam.Eye, viewCam.Target, UpPoint)
	Dim yAxis As UnitVector = EyeTargetUpPlane.Normal
	Dim oWap As WorkPlane = oCompDef.WorkPlanes.AddFixed(oCompDef.WorkPoints.Item(1).Point, xAxis, yAxis, True)
	Dim oSk As PlanarSketch
	Try
		oSk = oCompDef.Sketches.Item(oName)
		oSk.Delete
	Catch : End Try
	oSk = oCompDef.Sketches.Add(oWap)
	oSk.Name = oName
	Dim oCam As Camera
	oCam = oInvApp.ActiveView.Camera
	oCam.Target = viewCam.Target
	oCam.Eye = viewCam.Eye
	oCam.UpVector = viewCam.UpVector
	oCam.Fit()
	oCam.Apply()
	oCreateTmpView(oCompDef, oCam, oSk)
End Function
Function oCreateTmpView(oCompDef As ComponentDefinition, oViewCamera As Camera, oSk As PlanarSketch)
	Dim oDoc As DrawingDocument = oInvApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, , False)
	Dim oViewOrientation As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kArbitraryViewOrientation
	Dim oSht As Sheet = oDoc.ActiveSheet
	Dim oPntView As Point2d = oInvApp.TransientGeometry.CreatePoint2d(10, 10)
	Dim oScale As Double = 0.1
	Dim oViewStyle As DrawingViewStyleEnum = DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle
	Dim oVBase As DrawingView = oSht.DrawingViews.AddBaseView(oCompDef.Document, oPntView,
	oScale, oViewOrientation, oViewStyle, , oViewCamera, )
	For Each oDrawingCurve As DrawingCurve In oVBase.DrawingCurves
		Dim oSkent As SketchEntity
		Try
			oSkent = oSk.AddByProjectingEntity(oDrawingCurve.ModelGeometry)
		Catch
			Dim oPt As Point = oVBase.SheetToModelSpace(oDrawingCurve.MidPoint).
			IntersectWithSurface(oDrawingCurve.ModelGeometry.Geometry).Item(1)
			If Not oPt Is Nothing Then oSkent = oSk.AddBySilhouette(oDrawingCurve.ModelGeometry, oPt)
		End Try
	Next
	oDoc.Close(True)
End Function
Public Shared oInvApp As Inventor.Application

。 

0 Likes
Message 9 of 15

Stakin
Collaborator
Collaborator

Are you want this?Draw an outline at any view position;

Stakin_0-1747974944005.png

Stakin_1-1747975069445.png

Stakin_2-1747975098876.png

 

 

0 Likes
Message 10 of 15

Stakin
Collaborator
Collaborator

Try below,But it sometimes crashes and doesn't output. I don't know why this is so, it needs to be solved by a master.
If something goes wrong, Change view to another perspective.

The error is mainly that all sketch profile outlines cannot be selected when extrude at certain angles in the function of 'oSketchEnt', and the reason maybe  some sketch lines intersect but do not have a clear intersection point; As a result, an effective closed profilepath cannot be formed.It is hoped that a master will solve it.

@WCrihfield 

2025.5.26 edit

Stakin_0-1748252728132.png

Stakin_2-1748252877113.png

 

Examples of errors:

Stakin_1-1748252815968.png

Stakin_3-1748252917488.png

Option Explicit on
Public Sub Main()
	oInvApp = ThisApplication
	Dim oDoc As PartDocument = oInvApp.ActiveDocument
	Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim oName As String = "Silhouette"
	oCreateSilhouetteSketch(oDef, oName, oInvApp.ActiveView.Camera)
End Sub
Function oSketchEnt(oDef As PartComponentDefinition, oProfile As Profile, oName As String)
	Dim oExtrudeDef As ExtrudeDefinition
	oExtrudeDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kNewBodyOperation)
	oExtrudeDef.SetDistanceExtent(1, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection)
	Dim oExtrude As ExtrudeFeature = oDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
	oExtrude.Name = "Extrude_" & oName
	Dim obody As SurfaceBody = oExtrude.SurfaceBodies.Item(1)
	oCreateClientFeature(oDef, oName,  oProfile.Parent.PlanarEntity, obody)
	oExtrude.Delete(False, False, False)
	oDef.Document.selectset.select(oDef.Features.ClientFeatures.Item(1))
End Function
Function oCreateSilhouetteSketch(oCompDef As PartComponentDefinition, oInName As String, viewCam As Camera)
	Dim oViewDir As UnitVector = viewCam.Eye.VectorTo(viewCam.Target).AsUnitVector
	Dim xAxis As UnitVector = viewCam.UpVector.Copy
	Dim UpPoint As Point = viewCam.Eye.Copy
	UpPoint.TranslateBy(xAxis.AsVector)
	Dim EyeTargetUpPlane As Plane = oInvApp.TransientGeometry.CreatePlaneByThreePoints(viewCam.Eye, viewCam.Target, UpPoint)
	Dim yAxis As UnitVector = EyeTargetUpPlane.Normal
	Dim oWap As WorkPlane = oCompDef.WorkPlanes.AddFixed(oCompDef.MassProperties.CenterOfMass, xAxis, yAxis, True)
	Dim oWax As WorkAxis = oCompDef.WorkAxes.AddFixed(oCompDef.MassProperties.CenterOfMass, oViewDir, True)
	Dim oSk As PlanarSketch = oCompDef.Sketches.Add(oWap)
	oCreateTmpView(oCompDef, viewCam, oSk, oInName)
End Function
Function oCreateTmpView(oCompDef As PartComponentDefinition, oViewCamera As Camera, oSk As PlanarSketch, oName As String)
	Dim oDoc As DrawingDocument = oInvApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, , False)
	Dim oViewOrientation As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kArbitraryViewOrientation
	Dim oSht As Sheet = oDoc.ActiveSheet
	Dim oPntView As Point2d = oInvApp.TransientGeometry.CreatePoint2d(0, 0)
	Dim oScale As Double = 1
	Dim oViewStyle As DrawingViewStyleEnum = DrawingViewStyleEnum.kHiddenLineDrawingViewStyle
	Dim oVBase As DrawingView = oSht.DrawingViews.AddBaseView(oCompDef.Document, oPntView,
	oScale, oViewOrientation, oViewStyle, , oViewCamera, )
	Dim oDrawSketch As DrawingSketch = oVBase.Sketches.Add
	For Each oDrawingCurve As DrawingCurve In oVBase.DrawingCurves
		oDrawSketch.AddByProjectingEntity(oDrawingCurve)
	Next
	oDrawSketch.CopyContentsTo(oSk)
	Dim oSkCol As ObjectCollection = oInvApp.TransientObjects.CreateObjectCollection
	For Each oSkent As SketchEntity In oSk.SketchEntities
		oSkCol.Add(oSkent)
	Next
	Dim oPmt As Point2d = oVBase.ModelToDrawingViewSpace(oCompDef.MassProperties.CenterOfMass)
	oSk.MoveSketchObjects(oSkCol, oPmt.VectorTo(oPntView))
	oSk.RotateSketchObjects(oSkCol, oPntView, 3 * PI / 2, False, True)
		Dim oProfile As Profile
	oProfile = oSk.Profiles.AddForSolid(False, oSkCol, False)
	oDoc.Close(True)
	oSketchEnt(oCompDef, oProfile, oName)
End Function
Function oCreateClientFeature(oCompDef As PartComponentDefinition, oInName As String, oWp As WorkPlane, oBody As SurfaceBody)
	Dim oName As String = "BRep-" & oInName
	Dim oCf As ClientFeature
	Try
		oCf = oCompDef.Features.ClientFeatures.Item("[" & oName & "]")
		oCf.Delete
	Catch : End Try
	Dim oCfDef As ClientFeatureDefinition = oCompDef.Features.ClientFeatures.CreateDefinition()
	oCf = oCompDef.Features.ClientFeatures.Add(oCfDef, "[" & oName & "]")
	oCf.Name = "[" & oName & "]"
	oCfDef = oCf.Definition
	Dim oClientGraphics As ClientGraphics = oCfDef.ClientGraphicsCollection.Add(oName)
	Dim oSurfacesNode As GraphicsNode = oClientGraphics.AddNode(1)
	Dim oUnionBody As SurfaceBody
	Dim oColors As Color = oInvApp.TransientObjects.CreateColor(0, 255, 255)
	Dim oSk3d As Sketch3D = oCompDef.Sketches3D.Add
	Dim oIntersectionCurve As IntersectionCurve = oSk3d.IntersectionCurves.Add(oWp, oBody)
	oSk3d.Profiles3D.AddClosed
	Dim oEdges As List(Of Object) = oSk3d.Profiles3D.Cast(Of Profile3D).
	SelectMany(Function(x As Profile3D) x.cast(Of ProfilePath3D).ToList).
	SelectMany(Function(x As ProfilePath3D) x.Cast(Of ProfileEntity3D).Tolist).
	Select(Function(x As ProfileEntity3D) x.Curve).ToList
	For Each oedge As Object In oEdges
		Dim oCourve As CurveGraphics= oSurfacesNode.AddCurveGraphics(oedge)
		oCourve.Color = oColors
		oCourve.BurnThrough=True
		oCourve.LineWeight = 15
	Next
	oSk3d.Delete
End Function
Public Shared oInvApp As Inventor.Application

 

 

0 Likes
Message 11 of 15

WCrihfield
Mentor
Mentor

Unfortunately, I am still using Inventor Pro 2024.3.5 at work, so when I attempt to open either part, it acts like I am trying to 'derive' foreign geometry, with no modeling history, and no  rules.

I have never used this specific method before, which is one of the reasons I have not responded to this forum request yet.  Another reason is due to time constraints, because I had an idea that tackling this challenge might take a lot of time, a lot of trial & error testing, and might require dabbling into some areas that I don't frequently get into.  I have a lot less time for taking on large/complex Inventor automation tasks for others in the Autodesk Community this year than I did in previous years, due to some changes where I work, so I have been a bit more selective lately.  I did read through most of the code you posted above, but that is a lot to follow entirely in my head, so difficult to debug by proofreading alone.  There are things which could have been done differently, but nothing specific seemed like it would obviously cause errors.  I do a lot of copying sketch geometry between sketches in different documents, but it is usually between 'model' documents, not from a drawing sketch to a model sketch, so that part seemed a little suspicious to me, but just speculation.  I pretty much never create work features that are 'construction', unless I have code after that point which gets rid of them.  If you need to get the 'axis' that is perpendicular to the 'line of sight' and the 'up vector', then you could use the UnitVector.CrossProduct method.  The resulting UnitVector will be perpendicular to the one you called the method from, and the one you specified as input into the method.  That is commonly used for finding the third axis in a UCS scenario, when you only have two of the axes (line of sight & up vector in this case).  Plus, I have not really used 'ClientFeatures' or 'ClientGraphics' that that many times before...just some dabbling around in/with them out of curiosity on a handful of occasions, and not too recently.  The overall process being used there seems like overkill to me, but maybe that's just because I have no use for the 'results'.

 

P.S.  Maybe Mike Deck (MJDeck) would have some more useful insight into this method.  He has been a programmer/developer with Autodesk for a very long time, and has been helping us out on this forum occasionally since its inception, usually when requested specifically, or when the subject matter has to do with how the Inventor API stuff works, or if specific abilities are possible through the API.  He may have even been involved in creating the method.  He is probably pretty busy, so I try not to bug him all the time with questions or requests.  😄

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 12 of 15

J-Camper
Advisor
Advisor

I tried the Drawingview method myself, but had to add some extra prep steps in my full processor since you need a part file to be saved in order to create a drawing view of it.  I did make my part sketch directly instead of copying, I'm not sure if that would be enough to stabilize your rule.  It was only marginally faster than my current implementation, projecting all edges to a 2d Planar sketch. 

 

...

Dim bView As DrawingView = TempDrawing.ActiveSheet.DrawingViews.AddBaseView(ThisClass.tempPart, Position, 1, ViewOrientationTypeEnum.kArbitraryViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, , oCam, )


Dim skPlane As WorkPlane = oCompDef.WorkPlanes.AddFixed(TransientStartPlane.RootPoint, xAxis.AsUnitVector, yAxis.AsUnitVector)
Dim endPlane As WorkPlane = oCompDef.WorkPlanes.AddFixed(TransientEndPlane.RootPoint, xAxis.AsUnitVector, yAxis.AsUnitVector)

Dim sk As PlanarSketch = oCompDef.Sketches.Add(skPlane)
For Each dc As DrawingCurve In bView.DrawingCurves

	sk.AddByProjectingEntity(dc.ModelGeometry).Construction = False

Next

...

 

What both my current process and the drawing view process are missing is accounting for thru holes that can be seen through from a particular view direction.  Ideally that part of the sketch would not be included in the extrusion, but i don't know how to write logic for it when we are just projecting everything indiscriminately.

I'm basically looking for what the pre-select highlight shows when there is something obscuring the object you are pre-selecting:

JCamper_1-1748441950370.png

JCamper_3-1748442160404.png

 

 

 

 

0 Likes
Message 13 of 15

Stakin
Collaborator
Collaborator

So you needn‘t create the outline of that just create a clientgraphics. 

This situation should generally be under the assembly.just like:

Sub Main
	oInvApp = ThisApplication
	Dim oADoc As AssemblyDocument = oInvApp.ActiveDocument
	Dim oSelect As SelectSet = oADoc.SelectSet
	Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
	Dim oCC As ComponentOccurrence
	oCC = oInvApp.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a Occurrence")
	Dim oName As String = "Com_ClientGraphics"
	Dim oClientGraphics As ClientGraphics
	Try
		oClientGraphics = oADef.ClientGraphicsCollection.Item(oName)
		oClientGraphics.Delete
	Catch : End Try
	oClientGraphics = oADef.ClientGraphicsCollection.Add(oName)
	Dim oRGB1, oRGB2, oRGB3 As Integer
	oRGB1 = Math.Round(Rnd() * 255)
	oRGB2 = Math.Round(Rnd() * 255)
	oRGB3 = Math.Round(Rnd() * 255)
	Dim oColors As Color = oInvApp.TransientObjects.CreateColor(oRGB1, oRGB2, oRGB3)
	Dim oSurfacesNode As GraphicsNode = oClientGraphics.AddNode(1)
	oSurfacesNode.AllowSlicing = True
	oSurfacesNode.Selectable = True
	Dim oMatrix As Matrix = oCC.Transformation
	For Each oBody As SurfaceBody In oCC.SurfaceBodies
		Dim oTransientBRep As TransientBRep = oInvApp.TransientBRep
		Dim oAlternatebody As SurfaceBody = oTransientBRep.Copy(oBody)
		Call oTransientBRep.Transform(oAlternatebody, oMatrix)
		Dim oSurface As SurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oAlternatebody)
		oSurface.DepthPriority = 10 + Math.Round(Rnd() * 90)
		oSurface.BurnThrough = True
		oSurface.Color = oColors
	Next
	oSelect.Select(oSurfacesNode)
	ThisApplication.ActiveView.Update
	MessageBox.Show("Your select part are highlight", "Info")
	oSelect.Clear
	oClientGraphics.Delete
End Sub
Public Shared oInvApp As Inventor.Application

 

0 Likes
Message 14 of 15

J-Camper
Advisor
Advisor

That does not seem to provide the same outline graphics as native user selected outline:
CodeCodeUser SelectionUser Selection

I only want lines that represent boundaries of the actual solid, nothing extra.  This image is the intended output, crudely mouse drawn:
Crude representation of end resultCrude representation of end result

With that being said, I am changing gears from this approach for my current project.  I would still like to figure out how to capture something like this, but I'm not including this workflow in the project I'm currently working on anymore.

0 Likes
Message 15 of 15

Stakin
Collaborator
Collaborator

By now,to be this effect by clientgraphics

it can check at any view direction.

 

Stakin_0-1748577393895.png

Stakin_2-1748577554122.png

 

 

 

0 Likes