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

If symbol "XX" exist on drawing then...

Gwennberg
Advocate

If symbol "XX" exist on drawing then...

Gwennberg
Advocate
Advocate

Hi

I would like to activate a script if a specific symbol exist on the drawing. First I need to check that the symbol exist in the library because old drawingtemplates do not have the symbol.

BR/Goran

0 Likes
Reply
Accepted solutions (1)
751 Views
5 Replies
Replies (5)

WCrihfield
Mentor
Mentor
Accepted solution

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

EESignature

(Not an Autodesk Employee)

0 Likes

Gwennberg
Advocate
Advocate

Hi WCrihfield, thanks for your answer

Today I have a ilogic script that makes a pdf-file of the manufacture drawing. Now we need a control drawing there we can put out symbols which measure our staff should check then the parts arrive. So I would like to make two different drawings (pdf-files); one for manufacturing and one for control. 

My idea to solve this, is that I make a specific symbol on a unique layer. This symbol will be places on those measures we will control. My script will first hide the symbols and generate a manufacturing drawing and then light up and make the control pdf.

The new symbol will only exist in a new drawing template and on some drawing the symbol might not be placed so I need a check in the script that the template is new and that the symbol has been placed. Sounds OK?!?

//Goran

 

0 Likes

Gwennberg
Advocate
Advocate

Hi

Is it possible to check if the symbol exist on the drawing area (has been used)?

BR/Goran

0 Likes

WCrihfield
Mentor
Mentor

The short answer to your last question is yes.

If 'instances' (SketchedSymbol objects) of the SketchedSymbolDefinition have been placed on any of the drawing's sheets, you can find them by looping through each Sheet, and checking the Sheet.SketchedSymbols.Count first, to see if there area any SketchedSymbols on the sheet, then if there are, you can check further by loop through each SketchedSymbol object in the Sheet.SketchedSymbols collection, checking to see if its SketchedSymbol.Definition property points to the specific SketchedSymbolDefinition you are working with.  Does that make sense to you?

 

To implement this, I would put the code for this part after you have already searched for and found (or copied over) the main SketchedSymbolDefinition object you were initially looking for.  If you did not find the definition object, you will not find any instances, so no need to proceed to look for them.  If the definition was found, then you can proceed to check for placed instances of it using that definition object to compare against any 'instances' of it that may have been placed on any sheets, as mentioned above.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Gwennberg
Advocate
Advocate

Hi WCrihfield

Thanks for your help. I manage to solve the problem with help of your program to find out if the symbol exist in the drawingtemplate. Then I used "If oMySSDef.IsReferenced = True " to find if there where any symbols placed on the drawings sheets. Seems to work.

BR/Goran

0 Likes