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)
Thank you for the help,
Mike
Solved! Go to Solution.
Solved by MechMachineMan. Go to Solution.
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
anyone else with a possible suggestion
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
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
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
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
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
If you're at AU in Vegas.. I owe you a beer!
'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
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 ...
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 SubThis 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