Sorting symbols - existing values

Sorting symbols - existing values

Anonymous
Not applicable
634 Views
3 Replies
Message 1 of 4

Sorting symbols - existing values

Anonymous
Not applicable

I'm wondering if there is a way to automatically sorting sketch symbols into views using iLogic? I would like to create 2 criteria: Checks if there is a value in the symbol, if so it moves the symbol; eg. A1

So, and If A1 is inserted then the next one does not move to the same place as A1 only for the next 38mm.

 

This is my code:

 

 

Dim oDoc  As Document
oDoc = ThisApplication.ActiveDocument

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawDoc.ActiveSheet

'----------------- X
Dim x1 As Double
x1 = 7.6
Dim x2 As Double
x2 = 15.2
'----------------- Y
Dim y1 As Double
y1 = 0
Dim y2 As Double
y2 = 7.6



'find the symbol by name
For Each oSymbol In oDoc.ActiveSheet.SketchedSymbols
	If oSymbol.Name = "A1" Then 
		'find the text box by name/label
		For Each oTextBox In oSymbol.Definition.Sketch.Textboxes
			If oTextBox.Text = "A1" Then
				oString = oSymbol.GetResultText(oTextBox)
			End If
		Next	
			If oString = "" Then
			Else
'------

        For Each oSketchedSymbol As SketchedSymbol In oSheet.SketchedSymbols
            If oSketchedSymbol.Name = "A1" Then
                Dim oPoint As Point2d = oSketchedSymbol.Position
                Select Case oSheet.Size
                    Case DrawingSheetSizeEnum.k24x36InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case DrawingSheetSizeEnum.k18x24InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case Else
                        oPoint.X += x1
                        oPoint.Y += y1
                End Select
                If Not oPoint Is Nothing Then
                    oSketchedSymbol.Position = oPoint
                End If
            End If
        Next
'------
			End If
		
	End If
Next
'=================================================
For Each oSymbol In oDoc.ActiveSheet.SketchedSymbols
	If oSymbol.Name = "A2" Then 
		'find the text box by name/label
		For Each oTextBox In oSymbol.Definition.Sketch.Textboxes
			If oTextBox.Text = "A2" Then
				oString = oSymbol.GetResultText(oTextBox)
			End If
		Next	
			If oString = "" Then
			Else
'-----

        For Each oSketchedSymbol As SketchedSymbol In oSheet.SketchedSymbols
            If oSketchedSymbol.Name = "A2" Then
                Dim oPoint As Point2d = oSketchedSymbol.Position
                Select Case oSheet.Size
                    Case DrawingSheetSizeEnum.k24x36InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case DrawingSheetSizeEnum.k18x24InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case Else
                        oPoint.X += x1
                        oPoint.Y += y1
                End Select
                If Not oPoint Is Nothing Then
                    oSketchedSymbol.Position = oPoint
                End If
            End If
        Next
'-----
			End If
		
	End If
Next
'=================================================
For Each oSymbol In oDoc.ActiveSheet.SketchedSymbols
	If oSymbol.Name = "B1" Then 
		'find the text box by name/label
		For Each oTextBox In oSymbol.Definition.Sketch.Textboxes
			If oTextBox.Text = "B1" Then
				oString = oSymbol.GetResultText(oTextBox)
			End If
		Next	
			If oString = "" Then
			Else
'-----

        For Each oSketchedSymbol As SketchedSymbol In oSheet.SketchedSymbols
            If oSketchedSymbol.Name = "B1" Then
                Dim oPoint As Point2d = oSketchedSymbol.Position
                Select Case oSheet.Size
                    Case DrawingSheetSizeEnum.k24x36InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case DrawingSheetSizeEnum.k18x24InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case Else
                        oPoint.X += x1
                        oPoint.Y += y1
                End Select
                If Not oPoint Is Nothing Then
                    oSketchedSymbol.Position = oPoint
                End If
            End If
        Next
'-----
			End If
		
	End If
Next

 

And my sheet:

sheet.JPG

 

Thanks in advance

David

0 Likes
635 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I edit my code like this:

 

 

Dim oDrawDoc As DrawingDocument
	oDrawDoc = ThisApplication.ActiveDocument
Dim oPartList As PartsList
	oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
Dim oDWG As DrawingDocument = ThisDoc.Document
Dim oVendor As PartsListCell
Dim oDetail As PartsListCell
Dim oItem As PartsListCell
Dim invPartNumber As String
Dim invCharPosition As Integer

Dim oSheet As Sheet
  	oSheet = oDrawDoc.ActiveSheet
Dim oSheets As Sheets = oDWG.Sheets	
	
Dim oSymbols As SketchedSymbols
    oSymbols = oSheet.SketchedSymbols
Dim oSymbol As SketchedSymbol

Dim oViews As DrawingViews
Dim oView As DrawingView


Dim A1 As String
Dim POZ_1 As Integer
POZ_1 = 0
Dim POZ_2 As Integer
POZ_2 = 1
Dim POZ_3 As Integer
POZ_3 = 0
Dim POZ_4 As Integer
POZ_4 = 0
Dim POZ_5 As Integer
POZ_5 = 0
Dim POZ_6 As Integer
POZ_6 = 0


' Iterate through the contents of the parts list.
Dim i As Long
For i = 1 To oPartList.PartsListRows.Count
    'Get value from NR ID column
    oItem = oPartList.PartsListRows.Item(i).Item("SZT")
    oVendor = oPartList.PartsListRows.Item(i).Item("NR ID")
    'find a specific part number
	'------------A
    If oVendor.Value = "A1" Then
        A1 = oItem.Value
    End If
Next

On Error Resume Next

For Each oSymbol In oSymbols
	oTextBoxes = oSymbol.Definition.Sketch.TextBoxes
	For Each oTextBox In oSymbol.Definition.Sketch.TextBoxes
'##############################################---A1
If POZ_1 = 0 Then
    If oTextBox.Text = "A1" Then  
'moving symbol
		For Each oSketchedSymbol As SketchedSymbol In oSheet.SketchedSymbols
            If oSketchedSymbol.Name = "A1" Then
                Dim oPoint As Point2d = oSketchedSymbol.Position
                Select Case oSheet.Size
                    Case DrawingSheetSizeEnum.k24x36InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case DrawingSheetSizeEnum.k18x24InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case Else
                        oPoint.X += 7.6
                        oPoint.Y += 0
                End Select
                If Not oPoint Is Nothing Then
                    oSketchedSymbol.Position = oPoint
                End If
			End If
        Next
	
'set the prompted entry value
	Call oSymbol.SetPromptResultText(oTextBox, A1)  
'blocking position
	POZ_1 = 1
    End If
	
Else If POZ_2 = 0 Then
    If oTextBox.Text = "A1" Then  
'moving symbol
		For Each oSketchedSymbol As SketchedSymbol In oSheet.SketchedSymbols
            If oSketchedSymbol.Name = "A1" Then
                Dim oPoint As Point2d = oSketchedSymbol.Position
                Select Case oSheet.Size
                    Case DrawingSheetSizeEnum.k24x36InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case DrawingSheetSizeEnum.k18x24InDrawingSheetSize
                        oPoint.X = 0
                        oPoint.Y = 0
                    Case Else
                        oPoint.X += 15.2
                        oPoint.Y += 0
                End Select
                If Not oPoint Is Nothing Then
                    oSketchedSymbol.Position = oPoint
                End If
			End If
        Next
	
'set the prompted entry value
	Call oSymbol.SetPromptResultText(oTextBox, A1)  
'blocking position
	POZ_2 = 1
    End If
	End If
    Next
Next

 

It works fine, but this is my all symbols:

A1,A2,B1,B2,B3,C1,C2,D1,D10,D11,D12,D13,D2,D3,D4,D5,D6,D7,D8,D9,E1,E10,E2,E3,E4,E5,E6,E7,E8,E9,F1,F2,F3,F4,F5,G1,G2,G3,I1,I11,I12,I2,J1,J2,K1,K2,K3,K4,L1,L2,L3,L4,L5,N1,N2,N3,N4,N5,P1,P2,P3,S1,S2,S3,S4,S5,T1,T2,T3,U1,U2,U3,U4,U5,U6,U7,U8,V1,V2,W1,W2,W3,W4,W5,W6,W7,W8,X1,X2,X3,X4,Y1,Y2,Y3,Z1,Z2,Z3,Z4,Z5,Z6

and my positions:

 

 

POZ_1,POZ_2,POZ_3,POZ_4,POZ_5,POZ_6,POZ_7,POZ_8,POZ_9,POZ_10,POZ_11,POZ_12,POZ_13,POZ_14,POZ_15,POZ_16,POZ_17,POZ_18,POZ_19,POZ_20,POZ_21,POZ_22,POZ_23,POZ_24,POZ_25

 

 

A1 symbol must check 25 conditions, there will be a lot of code for all conditions, does anyone have any idea to shorten it?

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

A new thought came to me, maybe insert concrete symbols first and then move them one by one and count them in the end.

Someone has any ideas?

 

0 Likes
Message 4 of 4

Anonymous
Not applicable

hi, I would like to write a condition: if there is an entry in partlist eg A1, insert the symbol - from the library. Can anyone help me?

0 Likes