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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

how to edit groups in existing symbol by VB.net?

bdijkstra
4-Participant

how to edit groups in existing symbol by VB.net?

pfcDrawingExamples.vb only allows me to place new symbols based on existing symbols on disc.

I got the feeling it has something to do with the following line: symItem = drawing.CreateDetailItem(symInstructions)

How do I get the SymInstructions active on an existing symbol on the drawing?

 

 

Public Sub placeDetailSymbol(ByRef session As IpfcSession, ByVal groupName As String, _
Optional ByVal variableText As String = Nothing, _
Optional ByVal height As Double = 0)

Dim model As IpfcModel
Dim drawing As IpfcDrawing
Dim symbolDefinition As IpfcDetailSymbolDefItem
Dim point As CpfcPoint3D
Dim mouse As IpfcMouseStatus
Dim symInstructions As IpfcDetailSymbolInstInstructions
Dim position As IpfcFreeAttachment
Dim allAttachments As IpfcDetailLeaders
Dim symItem As IpfcDetailSymbolInstItem

Dim varTexts As IpfcDetailVariantTexts
Dim varText As IpfcDetailVariantText

Dim allGroups As IpfcDetailSymbolGroups
Dim groups As IpfcDetailSymbolGroups
Dim group As IpfcDetailSymbolGroup

Try
'======================================================================
'Get the current drawing
'======================================================================
model = session.CurrentModel
If model Is Nothing Then
Throw New Exception("Model not present")
End If
If Not model.Type = EpfcModelType.EpfcMDL_DRAWING Then
Throw New Exception("Model is not drawing")
End If
drawing = CType(model, IpfcDrawing)

'======================================================================
'Retrieve symbol definition from system
'======================================================================
symbolDefinition = drawing.RetrieveSymbolDefinition("detail_symbol_example", _
"./", _
Nothing, Nothing)

'======================================================================
'Allocate the symbol instance decription
'======================================================================
symInstructions = (New CCpfcDetailSymbolInstInstructions).Create(symbolDefinition)

'======================================================================
'Set the new values
'======================================================================

Select Case groupName
Case "ALL"
symInstructions.SetGroups(EpfcDetailSymbolGroupOption.EpfcDETAIL_SYMBOL_GROUP_ALL, Nothing)
Case "NONE"
symInstructions.SetGroups(EpfcDetailSymbolGroupOption.EpfcDETAIL_SYMBOL_GROUP_NONE, Nothing)
Case Else
allGroups = symInstructions.SymbolDef.ListSubgroups
group = getGroup(allGroups, groupName)
If Not group Is Nothing Then
groups = New CpfcDetailSymbolGroups
groups.Append(group)
symInstructions.SetGroups(EpfcDetailSymbolGroupOption.EpfcDETAIL_SYMBOL_GROUP_CUSTOM, groups)
End If
End Select

'======================================================================
'Create and display the symbol
'======================================================================
symItem = drawing.CreateDetailItem(symInstructions)
symItem.Show()

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

End Sub

 

Private Function getGroup(ByRef groups As CpfcDetailSymbolGroups, ByVal groupName As String) As IpfcDetailSymbolGroup
Dim group As IpfcDetailSymbolGroup
Dim groupInstrs As IpfcDetailSymbolGroupInstructions
Dim i As Integer

If groups.Count = 0 Then
Return Nothing
End If

For i = 0 To groups.Count - 1
group = groups.Item(i)
groupInstrs = group.GetInstructions()

If groupInstrs.Name = groupName Then
Return group
End If
Next

Return Nothing

End Function

0 REPLIES 0
Announcements


Top Tags