Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic ~ switch German Sketch Symbols to English Version...

31 REPLIES 31
SOLVED
Reply
Message 1 of 32
mdavis22569
951 Views, 31 Replies

Ilogic ~ switch German Sketch Symbols to English Version...

I'm trying to get more stuff sourced in the US, but all of my notes, finishes etc are in German. I need to get them to easily change over to English at a click of the button (code) if possible.  If not I'll have to make 2 drawings for each, one in English and one in German ..which I'm trying to avoid. 

 

 

 

Is it possible to have an ilogic code that would switch say Column A to Column B? (German notes to English ones) 

 

I would have 2 folders under my Drawing Resources/Sketched Symbols   One folder English, one German.  

 

I would also be changing the title block to an English version too ... 

 

I can provide a copy of the IDW if needed (but I'd like to learn to do it myself) 

 

 

a to b.PNG

 

Thank you for the help,

 

Mike 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

31 REPLIES 31
Message 21 of 32
mdavis22569
in reply to: mdavis22569

Attached is the idw ...

 

I need "a" to be "b" ....and "b"to be "a" via api/ilogic 

 

problem is there are about 20 symbols that need to do this .

 

 

Suggestions, ideas ...?

 

Layers won't work since I would still need to double symbol everything .. 

 

 

Thanks in advance

 

Mike 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

Message 22 of 32
mdavis22569
in reply to: mdavis22569

anyone else with a possible suggestion

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

Message 23 of 32

Hi Michael,

 

frankly, it is not clear to me that what you wanted to achieve exactly. firstly, the symbols in the sheet is actually instance of the symbol definitions which are listed in the node Sketched Symbols. Since you defined the definition with fix string (a, b respectively), you cannot modify the content of the symbol instance unless you  update the definition.

 

If you just wanted to swap the position of the symbol isntance, you can simply swap their positions. The code below is a demo. 

 

 

 

' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    oDrawDoc = ThisApplication.ActiveDocument
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oEachSymbol As sketchedSymbol    
    'position of 'a'
    Dim oPos_A As Point2da
    Dim oPos_B As Point2d
    Dim oSymbol_A As sketchedSymbol
    Dim oSymbol_B As sketchedSymbol
    For Each oEachSymbol In oSheet.SketchedSymbols
        If oEachSymbol.Definition.Name = nderungsindex a" Then
            ' store the position of 'a'
            oPos_A = oEachSymbol.Position  
            oSymbol_A = oEachSymbol
             

        End If
        
        If oEachSymbol.Definition.Name = nderungsindex b" Then
            ' store the position of 'b'
            oPos_B = oEachSymbol.Position  
            oSymbol_B = oEachSymbol
             
        End If
        
    Next
    
    'swap position 'a' and 'b'
    oSymbol_A.Position = oPos_B
    oSymbol_B.Position = oPos_A

symbols.png

Message 24 of 32

Hi Michael,

 

frankly, it is not clear to me that what you wanted to achieve exactly. firstly, the symbols in the sheet is actually instance of the symbol definitions which are listed in the node Sketched Symbols. Since you defined the definition with fix string (a, b respectively), you cannot modify the content of the symbol instance unless you  update the definition.

 

If you just wanted to swap the position of the symbol isntance, you can simply swap their positions. The code below is a demo. 

 

 

 

' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    oDrawDoc = ThisApplication.ActiveDocument
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oEachSymbol As sketchedSymbol    
    'position of 'a'
    Dim oPos_A As Point2da
    Dim oPos_B As Point2d
    Dim oSymbol_A As sketchedSymbol
    Dim oSymbol_B As sketchedSymbol
    For Each oEachSymbol In oSheet.SketchedSymbols
        If oEachSymbol.Definition.Name = nderungsindex a" Then
            ' store the position of 'a'
            oPos_A = oEachSymbol.Position  
            oSymbol_A = oEachSymbol
             

        End If
        
        If oEachSymbol.Definition.Name = nderungsindex b" Then
            ' store the position of 'b'
            oPos_B = oEachSymbol.Position  
            oSymbol_B = oEachSymbol
             
        End If
        
    Next
    
    'swap position 'a' and 'b'
    oSymbol_A.Position = oPos_B
    oSymbol_B.Position = oPos_A

symbols.png

Message 25 of 32

Xiaodong

 

Thank you for the reply 

 

 

the a and the b are the rows ..

 

I would like the anodize note first, and if I run the rule it would change over to Eloxiert note

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

Message 26 of 32

Try this. It's very sloppy and could be done a bit cleaner/better/more efficient for expanding to other symbols, but it should work:

 

    oDrawDoc = ThisApplication.ActiveDocument
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oEachSymbol As sketchedSymbol    
   
    Dim oPos_A As Point2d
    Dim oPos_B As Point2d

	oSYMBOLA = "Änderungsindex a"    'Change this line as required
        oSYMBOLB = "Änderungsindex b"    'Change this line as required

    Dim oSymbol_A As sketchedSymbol
    Dim oSymbol_B As sketchedSymbol
Dim oSymDefA As SketchedSymbolDefinition = oDrawDoc.SketchedSymbolDefinitions.Item(oSYMBOLA) Dim oSymDefB As SketchedSymbolDefinition = oDrawDoc.SketchedSymbolDefinitions.Item(oSYMBOLB) For Each oEachSymbol In oSheet.SketchedSymbols If oEachSymbol.Definition.Name = oSYMBOLA Then oPos_A = oEachSymbol.Position oEachSymbol.Delete oNewSymbol = oSheet.SketchedSymbols.Add(oSymDefB, oPos_A) oNewSymbol.Static = True
Else if oEachSymbol.Definition.Name = oSYMBOLB Then oPos_B = oEachSymbol.Position oEachSymbol.Delete oNewSymbol = oSheet.SketchedSymbols.Add(oSymDefA, oPos_B) oNewSymbol.Static = True End If Next 

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 27 of 32

Thank you Justin ..

 

this will get me going on the right path ... it'll be a pain to get it to work with 2 different at once..but I got it started. Might just be easier to do them one by one ...

 

We'll see...

 

but thank you. Here is a click of it working




Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

Message 28 of 32
mdavis22569
in reply to: mdavis22569

If you're at AU in Vegas.. I owe you a beer! 

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

Message 29 of 32

Sadly I don't my company will pay for me, and I don't think the folks at Autodesk would sponsor a trip for me to do a presentation on iLogic/vb.net for inventor users at AU 😞

What would you want modified for the code?
When I get time I would be able to change it to be a sub/function much like component replace when you can easily just keep calling the function to swap symbols.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 30 of 32

'MechMachineMan SymbolSwap
'Will toggle symbols on all sheets of the active document based - if symbols are mixed languages, they will remain mixed languages


Sub Main()

Dim oSheet As Sheet
Dim oDoc As Document = ThisApplication.ActiveDocument

For Each oSheet in oDoc.Sheets
	oSheet.Activate
	SymbolSwap("Änderungsindex a", "Änderungsindex b")
	SymbolSwap("Änderungsindex c", "Änderungsindex d")
Next

End Sub
   
Sub SymbolSwap(oSYMBOLA As String, oSYMBOLB As String)
    oDrawDoc = ThisApplication.ActiveDocument
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oEachSymbol As sketchedSymbol    
   
    Dim oPos_A As Point2d
    Dim oPos_B As Point2d

    Dim oSymDefA As SketchedSymbolDefinition = oDrawDoc.SketchedSymbolDefinitions.Item(oSYMBOLA)
    Dim oSymDefB As SketchedSymbolDefinition = oDrawDoc.SketchedSymbolDefinitions.Item(oSYMBOLB)

For Each oEachSymbol In oSheet.SketchedSymbols 

If oEachSymbol.Definition.Name = oSYMBOLA Then 
	oPos_A = oEachSymbol.Position 
	oEachSymbol.Delete 
	
	oNewSymbol = oSheet.SketchedSymbols.Add(oSymDefB, oPos_A)
        oNewSymbol.Static = True

Else if oEachSymbol.Definition.Name = oSYMBOLB Then 
	oPos_B = oEachSymbol.Position 
	oEachSymbol.Delete 
	
	oNewSymbol = oSheet.SketchedSymbols.Add(oSymDefA, oPos_B)
        oNewSymbol.Static = True

End If 
Next 

End Sub

This should make your day even better.

 

A further expansion would allow you to select documents from within a file browser and do batch documents, but that would require re-writing a lot of it to not include "ActiveDocument"... Which I dont have time for atm.

 

Cheers


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 31 of 32

I don't want to make 10 codes ...  for example

 

phosphating 

Anodizing

Lightly Sanded

Polished ..

 

 

list goes on and on ...

 

 

So I'm looking at trying to do a group one where each is listed in there.. I was able to get it to work on 2 at a time.    I would have change the a/b code for each to the next set of letters.

 

 

You do know you can submit to present a class at AU ..and they would cover some of the cost, maybe more than some ...      



Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

Message 32 of 32

Hmmm i might have to look into that!
Also, the 2nd code I posted as below as you to do that as per list, like you were asking. Simply add/remove more lines of
SymbolSwap("Änderungsindex a", "Änderungsindex b")
under the previous, where the words in quotes are you symbol definition names. (I made it look like an iLogic snippet)
@MechMachineMan wrote:
'MechMachineMan SymbolSwap
'Will toggle symbols on all sheets of the active document based - if symbols are mixed languages, they will remain mixed languages


Sub Main()

Dim oSheet As Sheet
Dim oDoc As Document = ThisApplication.ActiveDocument

For Each oSheet in oDoc.Sheets
	oSheet.Activate
	SymbolSwap("Änderungsindex a", "Änderungsindex b")
	SymbolSwap("Änderungsindex c", "Änderungsindex d")
Next

End Sub
   
Sub SymbolSwap(oSYMBOLA As String, oSYMBOLB As String)
    oDrawDoc = ThisApplication.ActiveDocument
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oEachSymbol As sketchedSymbol    
   
    Dim oPos_A As Point2d
    Dim oPos_B As Point2d

    Dim oSymDefA As SketchedSymbolDefinition = oDrawDoc.SketchedSymbolDefinitions.Item(oSYMBOLA)
    Dim oSymDefB As SketchedSymbolDefinition = oDrawDoc.SketchedSymbolDefinitions.Item(oSYMBOLB)

For Each oEachSymbol In oSheet.SketchedSymbols 

If oEachSymbol.Definition.Name = oSYMBOLA Then 
	oPos_A = oEachSymbol.Position 
	oEachSymbol.Delete 
	
	oNewSymbol = oSheet.SketchedSymbols.Add(oSymDefB, oPos_A)
        oNewSymbol.Static = True

Else if oEachSymbol.Definition.Name = oSYMBOLB Then 
	oPos_B = oEachSymbol.Position 
	oEachSymbol.Delete 
	
	oNewSymbol = oSheet.SketchedSymbols.Add(oSymDefA, oPos_B)
        oNewSymbol.Static = True

End If 
Next 

End Sub

This should make your day even better.

 

A further expansion would allow you to select documents from within a file browser and do batch documents, but that would require re-writing a lot of it to not include "ActiveDocument"... Which I dont have time for atm.

 

Cheers


 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report