cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

VB API - Keep Interference Highlighted when Moving 3D Model

lhoogeveen
17-Peridot

VB API - Keep Interference Highlighted when Moving 3D Model

I'm trying to create my own Creo Assembly Interference menu because of the gaps in the Creo Global Interference Analysis - Exclude Skeletons and Other Improvements. I've got it working pretty well except when the user rotates the model the highlighted models and/or interference will not stay highlighted when the user rotates or zooms the 3D Creo model. The out of the box Creo Interference Analysis is able keep things highlighted while moving the 3D model.

 

For the VB API, is there a way to keep the models/interferences highlighted while the user moves the model?

 

Here's the VB example PTC provides:

'Analyzing Interference
'======================================================================
'Function : showInterferences
'Purpose : This function finds the interference in an assembly,
' highlights the interfering surfaces, and calculates
' the interference volume.
'======================================================================
Public Sub showInterferences(ByRef session As IpfcBaseSession)

Dim model As IpfcModel
Dim assembly As IpfcAssembly
Dim globalEval As IpfcGlobalEvaluator
Dim globalInterferences As IpfcGlobalInterferences
Dim globalInterference As IpfcGlobalInterference
Dim selectionPair As IpfcSelectionPair
Dim selection1, selection2 As IpfcSelection
Dim interVolume As IpfcInterferenceVolume
Dim totalVolume As Double
Dim noInterferences As Integer
Dim i As Integer

Try
'======================================================================
'Get the current solid
'======================================================================
model = session.CurrentModel
If model Is Nothing Then
Throw New Exception("Model not present")
End If
If (Not model.Type = EpfcModelType.EpfcMDL_ASSEMBLY) Then
Throw New Exception("Model is not an assembly")
End If
assembly = CType(model, IpfcAssembly)

globalEval = (New CMpfcInterference).CreateGlobalEvaluator(assembly)

'======================================================================
'Select the list of interferences in the assembly
'Setting parameter to true will select only solid geometry
'Setting it to false will through an exception
'======================================================================
globalInterferences = globalEval.ComputeGlobalInterference(True)

If globalInterferences Is Nothing Then
Throw New Exception("No interference detected in assembly : " + assembly.FullName)
Exit Sub
End If

'======================================================================
'For each interference display interfering surfaces and calculate the
'interfering volume
'======================================================================
noInterferences = globalInterferences.Count
For i = 0 To noInterferences - 1
globalInterference = globalInterferences.Item(i)

selectionPair = globalInterference.SelParts
selection1 = selectionPair.Sel1
selection2 = selectionPair.Sel2
selection1.Highlight(EpfcStdColor.EpfcCOLOR_HIGHLIGHT)
selection2.Highlight(EpfcStdColor.EpfcCOLOR_HIGHLIGHT)

interVolume = globalInterference.Volume
totalVolume = interVolume.ComputeVolume()

MsgBox("Interference " + i.ToString + " Volume : " + totalVolume.ToString)
interVolume.Highlight(EpfcStdColor.EpfcCOLOR_ERROR)

Next

Catch ex As Exception
MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
Exit Sub
End Try
End Sub

 

1 REPLY 1

The real problem seems to be the interfering volume won't stay highlighted after moving the assembly but the parts will stay highlighted.

 

Is there any way to keep the interference volume highlighted while rotating?

 

selectionPair = globalInterference.SelParts
selection1 = selectionPair.Sel1
selection2 = selectionPair.Sel2
selection1.Highlight(EpfcStdColor.EpfcCOLOR_HIGHLIGHT) 'This code highlights the parts - they stay highlighted when rotating/zooming
selection2.Highlight(EpfcStdColor.EpfcCOLOR_HIGHLIGHT)

interVolume = globalInterference.Volume
totalVolume = interVolume.ComputeVolume()

MsgBox("Interference " + i.ToString + " Volume : " + totalVolume.ToString)
interVolume.Highlight(EpfcStdColor.EpfcCOLOR_ERROR) 'This code highlights the interfering volume - which disappears after moving the Creo models.

 

Top Tags