Visio Guy

Visio Guy Website & General Stuff => User-submitted Stuff => Topic started by: Lars-Erik on March 09, 2009, 06:49:06 PM

Title: Translation of stencils
Post by: Lars-Erik on March 09, 2009, 06:49:06 PM
A while back I made a document to easily translate stencils and documents, the result is a document that can read "language" files, and remember used translations. It will never ask you to translate the same word twice. You can import and export translation documents, etc. It will translate all open stencils and documents.

That said, it's something I did a time ago, its no where bug free or optimal, but it does the trick. Perhaps someone has a use for it, or parts of it.

So use it if you can, I will answer questions etc if there are any.

- Lars
Title: Re: Translation of stencils
Post by: davidoff on March 11, 2009, 07:44:18 PM
Downloaded but try to understand how it works ?
i know i should run macro but can you make a bit clear for me?
Title: Re: Translation of stencils
Post by: Lars-Erik on March 11, 2009, 07:55:59 PM
1- Open a stencil/document or multiple ones you want to translate
2- Open the translate.vsd
3- Make sure the document TO BE TRANSLATED is active
4- Run the macro TranslateStencil, using the Tools->Macro menu
5- Set the amount of custom properties should be checked per shape (I know this should be automated ;))
6- The macro will start asking you for translations... save them so youll never get asked for the same one twice

7- You can use list know translations to let visio show you what translations were used and stored (these will be automaticly used if it finds on of these words (not parts of only full words)) are found.
8- Remove know translations using the "Remove1Translation" macro
9- Reset all known translations using the "ResetKnownTranslations" macro
10- Store or reload known translations (so save or reload the list generated at step 7) using the import and export functions

- Lars
Title: Re: Translation of stencils
Post by: Visio Guy on March 11, 2009, 10:11:12 PM
Anybody got any ideas on how we could web-ify something like this and build an on-line database of translations? Might be cool to subscribe to the VG forum's Vis-translation web service or something cool like that, but I'm not sure how hard it would be to get it going--and to allow us all to easily add translations so that it grows and grows.
Title: Re: Translation of stencils
Post by: Lars-Erik on March 11, 2009, 10:17:02 PM
Cool plan, but rather tricky/time consuming to set up.

Also, the stencil would need tweaking, when I put this together I wasn't thinking of making it easy or foolproof, it just had to do what I needed it to.

I'll brainstorm on this some more tomorrow.

- Lars
Title: Re: Translation of stencils
Post by: Visio Guy on March 11, 2009, 11:45:03 PM
I was thinking of a web-based database of terms, nothing linked directly to stencils - just some sort of community resource.

Btw, watching the Dutch baseball team play Puerto Rico for the Group D championship in the World Baseball Classic. Bet you didn't know you guys even had a team, eh? :)
Title: Re: Translation of stencils
Post by: Lars-Erik on March 12, 2009, 07:10:35 AM
Specific to Visio terms then?

I knew we had a team, though I never seen them on TV or anything.
Title: Re: Translation of stencils
Post by: d310gece on May 19, 2014, 06:48:06 AM
Anyone still working for translation of stencils ? I have an idea how to make it. I'am currently working on it. I just missing few pieces of puzzle to make it work :) I've posted these questions in other place of these forums but didn't get the answer.

Ok, now about my drawing. I have shapes which are connected to excel cells. I use data graphic to format them and I need to change them from time to time. There is only one problem - data graphic changes the font when it is applied. I am looking for a way to disable it. I think that it is somewhere in text callout shape sheet but I am still new to all these things so I would really appreciate any help.
BTW I am working with Visio2007

And another question. Is it a way to make a group of shapes to be selected while pressing CTRL+A. Now when I press CTRL+A i got only group selected not members. Changes in behavior window doesn't solve that.
Title: Re: Translation of stencils
Post by: Yacine on May 19, 2014, 08:12:20 AM
I do work on a small translation tool, but not for stencils.
We translate data of the shapes of our drawing and intend to use Access as "dictionary".
Title: Re: Translation of stencils
Post by: d310gece on May 19, 2014, 01:06:26 PM
OK, I will try to explain what I am up to, I have wiring diagrams which I am trying to make multi language. So make Excel table with labels ID, English and French and write the values of text boxes. After that I use command buttons which run VBA to select all shapes in all sheets and apply them different data graphic. One button for English and another for French. I made two data graphics, one to display English and another French.  This is my solution.
The only problem is when I change all the font sizes and pharagraphing stuff and press the button, data graphic returns everything back. I wonder how to change that, so that data graphic wont change formating part of text callouts. I was looking in shape sheet of data graphic and callout, but my knowledge is not enough to solve it.
Title: Re: Translation of stencils
Post by: Yacine on May 19, 2014, 06:17:47 PM
Ah a frenchman!
Si je te comprend bien, ce n'est pas la traduction de stencil que tu cherches, mais bien comme moi la traduction de colonnes de valeurs completes.
A ton encontre, nous utilisons une solution propre à nous sur laquelle nous avons le contrôle. Les data graphics sont une solution MS difficile à maitriser.
Mais nous pouvons tout de même essayer de t'aider.
A propos comment faites vous pour obtenir les traductions?
Title: Re: Translation of stencils
Post by: d310gece on May 20, 2014, 04:47:57 AM
A French language was just an example :) I am from Lithuania :) so i had to use google translate to translate your post :)
I attached a print screen from my excel sheet. So I write english value in one column and lithuanian in other, then I link data with visio shapes, text boxes. So now I have both languages linked to shapes. Then I create two data graphics. Each data graphics show only values in one language. Then I add command buttons and write a VBA code.

Sub EN_Click()
 
Dim PagsObj As Visio.Pages
Dim PagObj As Visio.Page

Set PagsObj = ActiveDocument.Pages

' iterate through the collection of pages
For Each PagObj In PagsObj
ActiveWindow.Page = PagObj.Name

' Select all shapes
Application.ActiveWindow.SelectAll

' Apply the data graphic
Visio.ActiveWindow.Selection.DataGraphic = Visio.ActiveDocument.Masters("ENdata")
Next

' MsgBox "You have successfully selected English language"
End Sub

When I click button named EN, VBA selects all the shapes and apply them data graphic which show only English values. When I want different language I add another button to apply different data graphics.
If I need new language, I will add another column in excel and another command button with data graphic.

So far evertyhing is great. But as I mentioned, I can't find a way to manualy format text boxes, or should I say text callouts. Whenever I apply a data graphics it changes all formating. I would like to disable that function.
Title: Re: Translation of stencils
Post by: Yacine on May 22, 2014, 04:12:53 PM
Hi,
In the drawing explorer there is under Masters a "Text Callout" Master.
It's format defines the general appearance of the text callouts of the data graphics.
There are others too, related to other display options. Check it out.
Title: Re: Translation of stencils
Post by: d310gece on May 22, 2014, 05:39:15 PM
Thanks for replying. I was trying to change that master the way I need for the last few days, but can't get the result I want. I even installed Visio2010 to use the CalloutTargetRef function, but it is not working as I was expexting. It's returning only #REF. So I gues there is something wrong with the shape or callout. I also tried to insert CalloutCount function in the ShapeSheet of the cell with callout attached but I am getting 0.0000   Can't understand why it is like this
Title: Re: Translation of stencils
Post by: Yacine on May 22, 2014, 06:12:18 PM
If you try to do everything in VBA, it will be difficult.
Do the very necessary part with code and the rest with settings in a template.
Setup your template, prepare one linking of data, so the according masters get visible, then adjust to your needs.
Title: Re: Translation of stencils
Post by: d310gece on May 23, 2014, 06:13:24 AM
I am using VBA only for selecting all shapes and applying a data graphics to them. I was thinking that I can enter CalloutTargetRef function in shape sheet of callout master, so it would get the reference of shape to which it is attached. I will dig deeper into posibilities of this function, if its only for VBA then it's  no use for me.
I know what you mean, by saying, Setup template, but when I apply data graphics it uses only one Callout master to all of the shapes, that means that it makes formating of all callouts the same. The best way would be deleting or at least disabling, character section in callout master shape sheet. The only problem is that I can't find a way to do that  .... :)
Title: Re: Translation of stencils
Post by: d310gece on May 26, 2014, 06:42:10 PM
OK, back to translation thing :) CalloutTargetRef works with simple callouts, but I couldnt make it work with custom callouts or TextCallouts. All that data graphic thing became a deadend. I couldn't format values seperatly. So I started looking for another way. And found it  8) Now it's not perfect working but I am trying to make it work. ok, now about the idea.
I created a simple shape, linked data from excell, inserted text field with information from excel and added it document stencil. After that I added a VBA code to change the text field value in master. It works great, exept few things:
1. I had to make VBA on every page (easy part)
2. I cant add info in master shape sheet call Fields.Value through VBA(Type mismatch error when trying to set value to Prop.Row2), so I add a number in user defined cells and Fields.Value is calculated using if. At first sight it looked ok, but I noticed that values are not refreshing until I make Fields.Value cell formula local not inheritant.
I think there are two solutions, either to find a way to remove the error or to make a formula local every time I drop or copy master.
Any suggestions?
I suppose that there is unnecessary things in my code but I am just a beginer so any comments are highly appreciated

Sub LT_click()

    Dim vsoMaster As Visio.Master
    Dim vsoMasterCopy As Visio.Master
    Dim vsoShape As Visio.Shape
    Dim vsoCell As Visio.Cell
    Dim vsoCell2 As Visio.Cell
    Dim PagsObj As Visio.Pages
    Dim PagObj As Visio.Page
'Changing master on all pages
    Set PagsObj = ActiveDocument.Pages
    For Each PagObj In PagsObj
        Set PagsObj = ActiveDocument.Pages
        ActiveWindow.Page = PagObj.Name
'Selecting master
    Set vsoMaster = Visio.ActiveDocument.Masters.Item("TextTranslate")
    Set vsoMasterCopy = vsoMaster.Open
'Selecting shape in master
    Set vsoShape = vsoMasterCopy.Shapes.Item(1)
'Selecting cell to change in shape's shapesheet
    Set vsoCell = vsoShape.CellsU("User.kalba")
    vsoCell = 1  //Cell value is added and in the ShapeSheet text field there is formula =GUARD(IF(User.Kalba=1,Prop.Row_2,IF(User.Kalba=2,Prop.Row_3,"No Data")))
   
Set vsoCell2 = vsoShape.CellsU("Fields.value")

    vsoCell2 = Prop.Row2 //here I get an error
   
'Closing and clearing master and shape
    Set vsoShape = Nothing
    vsoMasterCopy.Close
    Set vsoMasterCopy = Nothing
    Set vsoMaster = Nothing
   
Next
End Sub
Title: Re: Translation of stencils
Post by: d310gece on May 27, 2014, 07:39:15 AM
Made a correction of my code and now I am happy :) The only thing is that I have to maintain formula in Fields.Value inherited by master

Sub LT_click()

  Dim mst As Visio.Master
  Dim mstCopy As Visio.Master
  Dim shp As Visio.Shape
  Dim cell As Visio.cell
 
  Set mst = Visio.ActiveDocument.Masters.Item("TextTranslate")
  Set mstCopy = mst.Open
  Set shp = mstCopy.Shapes(1)

    'changes in text field
    Set cell = shp.Cells("Fields.Value")
    cell.Formula = "Prop.Row_2"  //If I need other information to be displayed, I change this value in macro for other button
    Set shp = Nothing

  mstCopy.Close

  Set mstCopy = Nothing
  Set mst = Nothing

End Sub

Now I can tell the whole idea of translating the shapes in drawing and how I made it.
I  created a simple shape, linked data from excell, inserted text field with information from excel and added it document stencil. After that I added a VBA code to change the text field value in master. My shape has ID (for auto linking data from excell), LT(Lithuanian translation), EN(English translation). I add shapes from master called TextTranslate in my drawing, format them the way I need. After that I add two command buttons for language changing and assign them the code from above. I press the button and voula :)
When I will need another language, I will add another collumn in excel and another button in drawing with a little change in code.
I use this to make multilanguage wiring diagrams. Whenewher I need to add another language, I don't have to make all the wiring diagram again. 
Title: Re: Translation of stencils
Post by: Yacine on May 27, 2014, 07:49:33 PM
This doesn't seem right.
Since you have a database driven solution, you'd better make the switch outside of visio, where it is much easier to handle.
You write that you don't know if there would come more languages in future.
So easiest would be to have a "textDisplayed" field, display it in the shapes and in the DB overwrite that field with whatever other data you need.

Just a thought ...
Title: Re: Translation of stencils
Post by: d310gece on June 02, 2014, 12:07:36 PM
I've got your point. Your idea is great and I thought about that. The only problem is that in case of my absence in work other people might get confused :) So we declared the languages and I added all the needed columns and buttons. I understand thet this is not the best solution but it will do the job. Thanks for help and ideas