How to address a specific Sketched Symbol in iLogic by name

How to address a specific Sketched Symbol in iLogic by name

Anonymous
Not applicable
1,186 Views
4 Replies
Message 1 of 5

How to address a specific Sketched Symbol in iLogic by name

Anonymous
Not applicable

Hi all,

 

I have a small code written to move a sketched symbol in my title block when the page size changes. The symbol is a set of prompted text, which is used for sheet specific notes on the drawing. The one issue that I'm having is that I can't figure out how to address the symbol by name, only by it's number, which as you can imagine is problematic.

 

Any help on this will be appreciated!

 

If ActiveSheet.Size ="A2" Then
PointX = (ActiveSheet.Width/10) - 1 - 0.5 - (7.5/2)
PointY = 33.4 + 1
End If

If ActiveSheet.Size ="A1" Then
PointX = (ActiveSheet.Width/10) - 2 - 0.5 - (7.5/2)
PointY = 33.4 + 2
End If

If ActiveSheet.Size ="A0" Then
PointX = (ActiveSheet.Width/10) - 2 - 0.5 - (7.5/2)
PointY = 33.4 + 2
End If


Dim oPoint As Point2d
oPoint=ThisApplication.TransientGeometry.Createpoint2d(PointX,PointY)

ActiveSheet.Sheet.SketchedSymbols.Item(1).Position=oPoint

InventorVb.DocumentUpdate()

0 Likes
1,187 Views
4 Replies
Replies (4)
Message 2 of 5

Curtis_Waguespack
Consultant
Consultant

 

Hi Hassonm,

 

Here's a quick example.

 

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

 

 

 

'Iterate through each symbol in the active sheet
For Each oSymbol In ThisDrawing.Document.ActiveSheet.SketchedSymbols
	'look for the symbol by name
	If oSymbol.Name = "MECHANICAL NOTES" Then
		MessageBox.Show("Sketched Symbol Found", "iLogic")
	End If
Next 'next symbol	

EESignature

0 Likes
Message 3 of 5

Curtis_Waguespack
Consultant
Consultant

Here's a related rule I use to gather the insert point of a specific sketched symbol, that might or might not be helpful.

 

 

Dim MyArrayList As New ArrayList

'Define the drawing document
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDrawing.Document

'Define the symbol to look for
Dim sSymbol As String

'Iterate through each symbol in the active sheet
For Each oSymbol In oDrawDoc.ActiveSheet.SketchedSymbols
	'check for duplicates  
	If Not (MyArrayList.Contains(oSymbol.Name)) Then
	MyArrayList.add(oSymbol.Name)
	Else
	End If
Next

If MyArrayList.Count < 1 Then
MessageBox.Show("No sketched symbols found on this sheet", "iLogic")

Return
Else
End If


'get user input
sSymbol = InputListBox("Select one:", MyArrayList, MyArrayList(0), "iLogic", "List")

'Iterate through each symbol in the active sheet
i = 0
For Each oSymbol In oDrawDoc.ActiveSheet.SketchedSymbols
	'look for the symbol by name
	If oSymbol.Name = sSymbol Then
	i = i+1 'count symbol
	'get the symbol insert point
	Dim oSymbPoint As Point2d
    oSymbPoint = oSymbol.Position
	'provide user the symbol co-ordinates in an
	'input box, so it can be copied
	'MsgBox(oSymbPoint.x & " " & oSymbPoint.y)
	InputBox("Symbol Insert Co-ordinates" & vbLf & _
	"Symbol Name: " & oSymbol.Name & "(" & i & ") :", _
	"iLogic", oSymbPoint.x & " , " & oSymbPoint.y)
	Else 
	End If
Next 

EESignature

0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks Curtis,

 

If you don't mind, how would I create a code that looks for a specific sketched symbol "Notes" and move it to a pre-specifiede point, eg 0,0?

 

Thanks again

0 Likes
Message 5 of 5

Anonymous
Not applicable

PS: My symbol has numerous prompted entries that I don't want changed

0 Likes