ilogic and sketched symbols

ilogic and sketched symbols

Anonymous
Not applicable
4,282 Views
10 Replies
Message 1 of 11

ilogic and sketched symbols

Anonymous
Not applicable

I cant see anything to do with sketched symbols in ilogic?  can you use ilogic to swap out sketched symbols or change their scale?

0 Likes
Accepted solutions (1)
4,283 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
0 Likes
Message 3 of 11

Anonymous
Not applicable

thanks but i cant find any sketched symbol snippets in iLogic.  I can only manage simple stuff and dont want to go down the VBA editor and macro route, too hard for my already throbbing brain

0 Likes
Message 4 of 11

MjDeck
Autodesk
Autodesk
Accepted solution

Here's a sample rule that will set the scale of a sketched symbol.  This example works in Inventor 2011.  In this example SymbolA is the name of the symbol on the drawing and SymbolAScale is a numeric parameter in the drawing.  It could be modified to work in Inventor 2010: all that has to change is how you get SymbolAScale.

 

 Swapping out a symbol is more complicated, but it should be possible.  The rule would have to delete the symbol and then create a new one (from a different definition) at the same location and scale.  Do your symbols use Prompted Entry text?  The rule would be simpler if it doesn't have to support Prompted Entries.

 

 

Sub Main
 SetSymbolScale("SymbolA", SymbolAScale)
End Sub

Sub SetSymbolScale(symbolName As String, scale As Double)
  Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
  If (drawingDoc Is Nothing) Then Return
  If (scale <= 0) Then Return

  For Each sheetX As Sheet In drawingDoc.Sheets
    For Each sketched As SketchedSymbol In sheetX.SketchedSymbols
      If (sketched.Name = symbolName) Then
  	    sketched.Scale = scale
      End If
    Next
  Next
End Sub

 

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 11

Anonymous
Not applicable

thanks very much!  I have changed it to suit our needs.  I am sure you can thin out the code a lot but it seems to work...

 

Sub Main
SetSymbolScale("GM Title Block Logo", LogoScale)
End Sub

Sub SetSymbolScale(symbolName As String, scale As Double)
Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
If (drawingDoc Is Nothing) Then Return
If (scale <= 0) Then Return

For Each sheetX As Sheet In drawingDoc.Sheets
For Each sketched As SketchedSymbol In sheetX.SketchedSymbols
If (sketched.Name = symbolName) And ActiveSheet.Size= "A3" Then
sketched.Scale = 24
ElseIf (sketched.Name = symbolName) And ActiveSheet.Size= "A2" Then
sketched.Scale = 30
ElseIf (sketched.Name = symbolName) And ActiveSheet.Size= "A1" Then
sketched.Scale = 34
ElseIf (sketched.Name = symbolName) And ActiveSheet.Size= "A0" Then
sketched.Scale = 38
End If
Next
Next
End Sub
0 Likes
Message 6 of 11

MjDeck
Autodesk
Autodesk

Your code might run into trouble if the drawing has more than one sheet.  Here's a version that doesn't use ActiveSheet:

Sub Main
 SetSymbolScale("GM Title Block Logo", LogoScale)
End Sub

Sub SetSymbolScale(symbolName As String, scale As Double)
  Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
  If (drawingDoc Is Nothing) Then Return
  If (scale <= 0) Then Return

 For Each sheetX As Sheet In drawingDoc.Sheets
    sheetSize = ThisDrawing.Sheet(sheetX.Name).Size
    For Each sketched As SketchedSymbol In sheetX.SketchedSymbols
      If (sketched.Name = symbolName) And sheetSize= "A3" Then
          sketched.Scale = 24
        ElseIf (sketched.Name = symbolName) And sheetSize= "A2" Then
          sketched.Scale = 30
        ElseIf (sketched.Name = symbolName) And sheetSize= "A1" Then
          sketched.Scale = 34
        ElseIf (sketched.Name = symbolName) And sheetSize= "A0" Then
          sketched.Scale = 38
      End If
    Next
  Next
End Sub

 

Do you still want to swap symbols: replace one symbol with another?  Does this logo include any text?  If so, does it use Prompted Entry text or is it driven by iProperties?

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 7 of 11

Anonymous
Not applicable

thanks again

0 Likes
Message 8 of 11

bruce.blundell
Participant
Participant

Hi Mike,

 

I am looking at replacing a sketch symbol within a drawing

 

any help on how to delete and add at the same location

 

as you previously mentioned

 

Regards

Bruce

0 Likes
Message 9 of 11

Curtis_Waguespack
Consultant
Consultant

Hi @bruce.blundell,

 

Welcome to the forums, see this link, I think it is close to what you're after:

https://forums.autodesk.com/t5/inventor-forum/ilogic-for-sketched-symbols/td-p/5838992

 

Feel free to start a new topic on the Inventor Customization forum if you need to modify it further, etc.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 10 of 11

Anonymous
Not applicable

What would I add or change to make the scale change only in the active sheet?  

 

Also, what would I add to make the scale change only on sheets where the name starts with "Sheet - Phase"?

 

Thank you for any and all help with this.  This code works great for the full document but I'm having a hard time converting it to do the specific sheet or sheets that I want.

 

Thank you, Ryan.

0 Likes
Message 11 of 11

MjDeck
Autodesk
Autodesk

@Anonymous, here's a rule that gives you both options. For easy testing, I took out the custom scaling code is in some of the versions above. You should be able to add that back in if you need it.

Sub Main
	SetSymbolScale("SymbolX", LogoScale, True) ' Change only the active sheet
	SetSymbolScale("SymbolX", LogoScale, False, "Sheet - Phase") ' Change only sheets that start with a prefix
End Sub

Sub SetSymbolScale(symbolName As String, scale As Double, activeSheetOnly As Boolean, Optional sheetPrefix As String = "")
	Dim drawingDoc As DrawingDocument = TryCast(ThisDoc.Document, DrawingDocument)
	If (drawingDoc Is Nothing) Then Return
	If (scale <= 0) Then Return

	For Each sheetX As Sheet In drawingDoc.Sheets
		If Not (activeSheetOnly AndAlso sheetX IsNot drawingDoc.ActiveSheet) Then
			If String.IsNullOrEmpty(sheetPrefix) OrElse sheetX.Name.StartsWith(sheetPrefix, StringComparison.OrdinalIgnoreCase) Then
				sheetSize = ThisDrawing.Sheet(sheetX.Name).Size
				For Each sketched As SketchedSymbol In sheetX.SketchedSymbols
					sketched.Scale = scale
				Next
			End If
		End If
	Next
End Sub

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes