Hi @Gwennberg. Can you include more details about what you want and are trying to accomplish overall. What specifically do you mean by "activate a script"? By symbol, are we talking about a SketchedSymbolDefinition object here, or something else? If you just want the code to check if this 'symbol' exists within a drawing document, then why would we also need to know if it exists in some external library? What do you want to do with the symbol if it is found? What do you want to happen if it is not found? If it is found, do you want to delete any instances (SketchedSymbol objects) of it that have been placed on any of the drawings sheets? Do you want to replace existing ones, instead of delete them?
Here is something that may give you a head start if some of my assumptions are correct:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.", vbCritical, "iLogic")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
oSSDefs = oDDoc.SketchedSymbolDefinitions
Dim oMySSDef As SketchedSymbolDefinition = Nothing
If oSSDefs.Count > 0 Then
For Each oSSDef As SketchedSymbolDefinition In oSSDefs
If oSSDef.Name = "XX" Then
oMySSDef = oSSDef
End If
Next
End If
If oMySSDef Is Nothing Then
MsgBox("It was Not Found.",,"")
'could ask user if they want to import it from library
'oLib = oSSDefs.SketchedSymbolDefinitionLibraries.Item(1)
'oMySSDef = oSSDefs.AddFromLibrary(oLib, "XX", False)
Else 'it was found, so replace it from library source
MsgBox("It was Found.",,"")
'message user, say it was found, ask if they want to replace it from library
'oLib = oSSDefs.SketchedSymbolDefinitionLibraries.Item(1)
'oMySSDef = oSSDefs.AddFromLibrary(oLib, "XX", True)
End If
Wesley Crihfield

(Not an Autodesk Employee)