Inventor Customization

Reply
Mentor
tuliobarata
Posts: 164
Registered: ‎11-30-2007
Message 1 of 4 (469 Views)
Accepted Solution

Create or Edit text n a Symbol

469 Views, 3 Replies
11-01-2012 04:18 AM

Good Morning all!

 

To make my drawing notes here, I'm with other idea now, maybe easier:

With iLogic, define some pre notes and when the user choose one option some notes are chosen too.

The idea now is: Create a text direct inside on Sketched Symbol OR edit some textfields inside the Symbol.

The symbol could be one existent, so its not necessary to create it.

 

I got a code to create the text, and that works perfectly! Just what im trying now is create this text into the Symbol... I've tried many ways with reference from:

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Creating-Intelligent-sketched-symbols/...

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Sketched-Symbol-with-prompt-text-and-I...

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Sketched-symbol-with-custom-property/m...

 

but i didnt found a solution for it, how could I make it then guys ?

The code to create the tet im usnig is this one:

    '  a reference to the drawing document.    ' This assumes a drawing document is active.    Dim oDrawDoc As DrawingDocument
     oDrawDoc = ThisApplication.ActiveDocument

    '  a reference to the active sheet.    Dim oActiveSheet As Sheet
     oActiveSheet = oDrawDoc.ActiveSheet
    
    '  a reference to the GeneralNotes object    Dim oGeneralNotes As GeneralNotes
     oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
    
    Dim oTG As TransientGeometry
     oTG = ThisApplication.TransientGeometry

    ' Create text with simple string as input. Since this doesn't use    ' any text overrides, it will default to the active text style.    Dim sText As String
    sText = "NOTAS"
    
    Dim oGeneralNote As GeneralNote
     oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(3, 16), sText)

    Dim dYCoord As Double
    dYCoord = 14
    Dim dYOff As Double
    Dim oStyle As TextStyle
     oStyle = oGeneralNotes.Item(1).TextStyle
    dYOff = oStyle.FontSize * 1

    '1º Nota    sText = "1) This is note 1" & vbCrLf & "segunda linha" & vbCrLf & "terceira linha."
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText)

    '2º Nota    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + 0.2)
    sText = "2) teste"
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText)

 

but, if i could just edit one existent text filed into the symbol would be great too :smileyhappy:

 

and one "extra doubt", in all the codes that i get here, i have to erase the "public sub" and the "set" from all code, am I doing something wrong ? I'm running directly from the iLogic window.

 

Thanks

Túlio Barata

 

 

IV 2013
Mentor
tuliobarata
Posts: 164
Registered: ‎11-30-2007
Message 2 of 4 (463 Views)

Re: Create or Edit text n a Symbol

11-01-2012 10:57 AM in reply to: tuliobarata

Hi all!

 

I almost finished the code, just new now to know how to put the text it creates into a symbol :smileyhappy:.

It gives me a little of work creating parameters and conditions, actually dunno if there is a easier way, but the result is nice and usefull here :smileyhappy:

Its basiclly one form that you can choose if wanna use 2 languages, 5 types of predefined notes and some custom.

follow the code:

 

 

'Idioma para os titulosDim Tit_ID1,Tit_ID2 As String

'INICIO - Seleção de idiomato para os titulosSelect Case ref_ID1
Case "EN"
Tit_ID1    = "NOTES:"
Case "ES"
Tit_ID1    = "NOTAS:"
Case "FR"
Tit_ID1    = "NOTES:"
Case "PT"
Tit_ID1    = "NOTAS:"
End Select
Select Case ref_ID2
Case "EN"
Tit_ID2    = "NOTES:"
Case "ES"
Tit_ID2    = "NOTAS:"
Case "FR"
Tit_ID2    = "NOTES:"
Case "PT"
Tit_ID2    = "NOTAS:"
End Select
'FIM - Seleção de idiomato para os titulos

'INICIO - Verificação se ha necessidade de um idioma secundarioIf  ref_ID2 = "0 - Sem idioma secundario" Then
ref_ID = False
Else
ref_ID = True
End If
'FIM - Varificação se ha necessidade de um idioma secundario

'INICIO - Seleção do conteudo de cada linha da nota com 2 idiomasSelect Case ref_Nota

Case "0 - Notas em branco"
'-----------------------------------------------------------------------------------------------------------------------        Case "1 - Notas para montagens gerais"

Select Case ref_ID1
Case "EN"
Nota1_ID1 = "01) TO MANUFACTURE= " & qtd_itens & " ASSEMBLY(IES)."
Nota2_ID1 = "02) BILL OF MATERIALS FOR 01 ASSEMBLY."
Nota3_ID1 = "03) DIMENSIONS IN mm, EXCEPT WHERE INDICATED."
Case "ES"
Case "FR"
Case "PT"
Nota1_ID1 = "01) CONFECCIONAR= " & qtd_itens & " CONJUNTO(S)."
Nota2_ID1 = "02) LISTA DE MATERIAL PARA 01 CONJUNTO."
Nota3_ID1 = "03) DIMENSÕES EM mm, EXCETO ONDE INDICADO."
End Select

Select Case ref_ID2
Case "EN"
Nota1_ID2 = "01) TO MANUFACTURE= " & qtd_itens & " ASSEMBLY(IES)."
Nota2_ID2 = "02) BILL OF MATERIALS FOR 01 ASSEMBLY."
Nota3_ID2 = "03) DIMENSIONS IN mm, EXCEPT WHERE INDICATED."
Case "ES"
Case "FR"
Case "PT"
Nota1_ID2 = "01) CONFECCIONAR= " & qtd_itens & " CONJUNTO(S)."
Nota2_ID2 = "02) LISTA DE MATERIAL PARA 01 CONJUNTO."
Nota3_ID2 = "03) DIMENSÕES EM mm, EXCETO ONDE INDICADO."
End Select

'-----------------------------------------------------------------------------------------------------------------------        Case "2 - Submontagens SEM det. de usinagem"

Select Case ref_ID1
Case "EN"
Nota1_ID1 = "01) TO MANUFACTURE= " & qtd_itens & " ASSEMBLY(IES) PER EQUIPMENT."
Nota2_ID1 = "02) BILL OF MATERIALS FOR 01 ASSEMBLY."
Nota3_ID1 = "03) DIMENSIONS IN mm, EXCEPT WHERE INDICATED."
Case "ES"
Case "FR"
Case "PT"
Nota1_ID1 = "01) CONFECCIONAR= " & qtd_itens & " CONJUNTO(S) POR EQUIPAMENTO."
Nota2_ID1 = "02) LISTA DE MATERIAL PARA 01 CONJUNTO."
Nota3_ID1 = "03) DIMENSÕES EM mm, EXCETO ONDE INDICADO."
End Select

Select Case ref_ID2
Case "EN"
Nota1_ID2 = "01) TO MANUFACTURE= " & qtd_itens & " ASSEMBLY(IES) PER EQUIPMENT."
Nota2_ID2 = "02) BILL OF MATERIALS FOR 01 ASSEMBLY."
Nota3_ID2 = "03) DIMENSIONS IN mm, EXCEPT WHERE INDICATED."
Case "ES"
Case "FR"
Case "PT"
Nota1_ID2 = "01) CONFECCIONAR= " & qtd_itens & " CONJUNTO(S) POR EQUIPAMENTO."
Nota2_ID2 = "02) LISTA DE MATERIAL PARA 01 CONJUNTO."
Nota3_ID2 = "03) DIMENSÕES EM mm, EXCETO ONDE INDICADO."
End Select

'-----------------------------------------------------------------------------------------------------------------------        Case "3 - Submontagens COM det. de usinagem"

End Select
'FIM - Seleção do conteudo de cada linha da nota com 2 idiomas    
    
'INICIO - Criação dos textos    
    'coordenadas e espaçamentos    Dim dYCoord,dXCoord,dXCoord_,dY00,dY11,dY12 As Double
    'coordenada inicial de posicionamento em Y    dYCoord = -5
    'coordenada inicial de posicionamento em X    dXCoord = 0
    'deslocamento em X das notas no idioma secundario    dXCoord_ = dXCoord+0
    'espaçamento inicial entre o titulo e a primeira linha da nota    dY00 = 0.3
    'espaçamento entre as linhas do idioma primario    dY11 = 0.2
    'espaçamento entre as linhas do idioma secundario    dY12 = 0.05
    
    '  a reference to the drawing document.    ' This assumes a drawing document is active.    Dim oDrawDoc As DrawingDocument
     oDrawDoc = ThisApplication.ActiveDocument
    '  a reference to the active sheet.    Dim oActiveSheet As Sheet
     oActiveSheet = oDrawDoc.ActiveSheet
    '  a reference to the GeneralNotes object    Dim oGeneralNotes As GeneralNotes
     oGeneralNotes = oActiveSheet.DrawingNotes.GeneralNotes
    Dim oTG As TransientGeometry
     oTG = ThisApplication.TransientGeometry

    ' Create text with simple string as input. Since this doesn't use    ' any text overrides, it will default to the active text style.       Dim oGeneralNote As GeneralNote
'-----------------------------------------------------------------------------------------------------------------------            'Titulo ID1         oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord, dYCoord), Tit_ID1,"COMUMT3")
    'Titulo ID2     If  ref_ID = True Then
        dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY12)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord_, dYCoord), Tit_ID2,"NOTA_L2")
    End If
    
'-----------------------------------------------------------------------------------------------------------------------            '1º Nota ID1    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY00)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord, dYCoord), Nota1_ID1,"NOTA_L1")
    '1º Nota ID2    If  ref_ID = True Then
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY12)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord_, dYCoord), Nota1_ID2,"NOTA_L2")
    End If
        
'-----------------------------------------------------------------------------------------------------------------------             '2º Nota ID1    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY11)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord, dYCoord), Nota2_ID1,"NOTA_L1")
    '2º Nota ID2    If  ref_ID = True Then
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY12)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord_, dYCoord), Nota2_ID2,"NOTA_L2")
    End If
    
'-----------------------------------------------------------------------------------------------------------------------        '3º Nota ID1    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY11)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord, dYCoord), Nota3_ID1,"NOTA_L1")
    '3º Nota ID2    If  ref_ID = True Then
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY12)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord_, dYCoord), Nota3_ID2,"NOTA_L2")
    End If
    
'-----------------------------------------------------------------------------------------------------------------------        '4º Nota ID1    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY11)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord, dYCoord), Nota4_ID1,"NOTA_L1")
    '4º Nota ID2    If  ref_ID = True Then
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY12)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord_, dYCoord), Nota4_ID2,"NOTA_L2")
    End If
    
'-----------------------------------------------------------------------------------------------------------------------        '5º Nota ID1    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY11)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord, dYCoord), Nota5_ID1,"NOTA_L1")
    '5º Nota ID2    If  ref_ID = True Then
    dYCoord = dYCoord - (oGeneralNote.FittedTextHeight + dY12)
    oGeneralNote = oGeneralNotes.AddFitted(oTG.CreatePoint2d(dXCoord_, dYCoord), Nota5_ID2,"NOTA_L2")
    End If    
    
'-----------------------------------------------------------------------------------------------------------------------    


Well, if someone knows how to put it into a symbol, plz tell me :smileyvery-happy:

 

 

Thanks all!

Túlio Barata

IV 2013
Mentor
tuliobarata
Posts: 164
Registered: ‎11-30-2007
Message 3 of 4 (449 Views)

Re: Create or Edit text n a Symbol

11-05-2012 04:29 AM in reply to: tuliobarata

Hi again!

 

Sry for answering again to my own post, but with some tries on weekend now I can edit one existent symbol. With the code below I verify if the symbol is already inserted in the sheet, and if yes it delete the symbol, then insert again.

The problem now is how to put my code to create those notes, inside this symbol insertion.

Should i change any code, like the GeneralNotes for something of SketchedSymbols ? I tried by some ways here, but in all of then i got errors.

 

One detail that i didnt put in this code, is to verify if the symbol is already created or not..I'm using one symbol that i created manually.

 

The code that im using to insert the symbol:

 

 

Dim oDrawDoc As DrawingDocument  
 oDrawDoc = ThisApplication.ActiveDocument
'Update the document    oDrawDoc.Update

Dim oSheets As Sheets
oSheets = oDrawDoc.Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oSymbol As SketchedSymbol
Dim oSymbols As SketchedSymbols

'iterate through all of the sheetsFor Each oSheet In oSheets
    'remove existing sketched symbols named View Label     For Each oSymbol  In oSheet.SketchedSymbols
    If oSymbol.Definition.Name = "Notas" Then
    oSymbol.Delete
    Else 
    End If
    Next
Next


' Set a reference to the drawing document.  ' This assumes a drawing document is active.       




 
' Create the new sketched symbol definition.    Dim oSketchedSymbolDef As SketchedSymbolDefinition    
 oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions("Notas")
 
' Open the sketched symbol definition's sketch for edit. This is done by calling the Edit    ' method of the SketchedSymbolDefinition to obtain a DrawingSketch. This actually creates    ' a copy of the sketched symbol definition's and opens it for edit. 
Dim oSketch As DrawingSketch    
Call oSketchedSymbolDef.Edit(oSketch)





'HERE I SHOUL PUT MY CODE TO CREATE THE TEXT, BUT ISNT WORKING USING THE CODE FROM OTHER POST.



Call oSketchedSymbolDef.ExitEdit(True)

'Set a reference to the active sheet.    Dim oDrgSheet As Sheet    
 oDrgSheet = oDrawDoc.ActiveSheet
 
' Set a reference to the sheet's border    Dim oBorder As Border     
oBorder = oDrgSheet.Border
Dim oPlacementPoint As Point2d
 
   If Not oBorder Is Nothing Then        
     ' A border exists. The placement point             ' is the top-right corner of the border.         oPlacementPoint = oBorder.RangeBox.MaxPoint     
 Else        
    ' There is no border. The placement point            ' is the top-right corner of the sheet.         oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oDrawDoc.Width, oDrawDoc.Height)    
  End If
 
' Add an instance of the sketched symbol definition to the sheet.    ' Rotate the instance by 0 degrees and scale by 1 when adding.    ' The symbol will be inserted at the upper right corner of the sheet.     Dim oSketchedSymbol As SketchedSymbol    
 oSketchedSymbol = oDrgSheet.SketchedSymbols.Add(oSketchedSymbolDef, oPlacementPoint, (0), 1)
 


Now i guess the code is almost complete...almost :smileyfrustrated:

 

Thanks again!

 

Túlio Barata

IV 2013
Mentor
tuliobarata
Posts: 164
Registered: ‎11-30-2007
Message 4 of 4 (432 Views)

Re: Create or Edit text n a Symbol

11-06-2012 11:45 AM in reply to: tuliobarata

The problem is that i was using GeneralNotes, i guess that doesnt work on Symbols, now im using TextBoxes as the code below and its working perfectly!

 

 

'Abre o symbol para edição
Dim oSketch As DrawingSketch
Call oSketchedSymbolDef.Edit(oSketch)
Dim oTextBox As TextBox

'1º Nota ID1dYCoord = dYCoord - (oTextBox.FittedTextHeight + dY00)
If Not Nota1_ID1="" Then
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(dXCoord, dYCoord), Nota1_ID1,"NOTA_L1")
End If 
'1º Nota ID2If ref_ID = True And Nota1_ID2 <> "" Then
dYCoord = dYCoord - (oTextBox.FittedTextHeight + dY12)
oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(dXCoord_, dYCoord), Nota1_ID2,"NOTA_L2")
End If

 

Thanks!

Túlio Barata

 

IV 2013

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube