create automated stencil in visio

Started by flow3rgirlz, December 05, 2008, 05:50:31 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

flow3rgirlz

Hi visio guy,

Is there any way to create automated stencil in visio based on a text file using any .NET programming language?

Paul Herber

Download the Visio SDK and have a look at John Marshall's site http://visio.mvps.org/ for VBA coding examples.

Tell us more about what you want to do?

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

flow3rgirlz

#2
Hi,

So basically what i want to do is
1. read from a given text file which contains the drawing (electronic block which have input and output)
2. draw the component in visio
3. save it as master in stencil

so basically the function is to create a stencil in visio automatically rather than drawing it out

do anyone have a sample code which i can refer as guide to do my program.


Lars-Erik

This is a way to read a text file line by line

Sub ImportTextFile()
Dim FileObject As New FileSystemObject
Dim TextFile

Ask the user for the filename of the textfile (with this code it looks for the file in the same directory as the visio document

FilePath = InputBox("Please enter the file name of your library, it should be in the folder of the selected file", "Import")
Set TextFile = FileObject.OpenTextFile(Visio.ActiveDocument.Path & FilePath & ".txt")

Loop the textfile line by line

Do Until TextFile.AtEndOfStream
ImportText = TextFile.ReadLine

Do something with the imported textline

Call UsedTranslations.Add(ImportText)

Go to the next line

Loop
MsgBox ("File has been succesfully imported")
End Sub

Some error handling might be smart depending on who you want to use your document.

- Lars

flow3rgirlz

#4
Hi,

Thanks for the reply. I manage to read the text file. Now, what i need to do is to draw the diagram and save it as master in stencil. I need some help to do this.

The sample diagram that i want to draw is

The diagram will looks like this



my main problem is how to save it as master in stencil. Thanks in advance...

Paul Herber

Where is this data coming from? It looks like the output from an electronics design package, not one that I recognise though, it's not the usual VHDL.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

flow3rgirlz

Hi,

This data is from my company. Yes, it is electronic design package.

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

flow3rgirlz

Its a .wys file format. No idea which electronic language it follows

Paul Herber

Can you attach a complete file, or email it to me if you don't want to make it public.
If done a search for any files similar to your example above, I found only one similar file and that was on website called kxcad.net and then I got redirected from there to a site about autogyros or something.

Formats like this often rely on library files that define all the words used within the language, now, I'm assuming that the example you posted is just a small part of the file, there is very little in the example that can be used to create the example shape. So, the more you can provide the better.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Paul Herber

Google finds nothing at all for the .wys file extension. Is it a home-brewed file format?
Can you attach a complete file?


Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

flow3rgirlz

Its a company file. I'm afraid that i need to ask the permission first as i just started to work there. Basically what my manager told me is just using the data that i pasted to draw the diagram.

wapperdude

Is this for documentation only? 

It looks like your symbol needs to track node types, i.e., input, inverted input, output, among other things.  If it's just documentational, then it ought to be relatively easy (I'm not a programmer  ::) ) to plop down a rectangle, input/output lines, add some connect pins, and text.  This can be down in VBA or C#, for example.  See  http://msdn.microsoft.com/en-us/library/aa200947(office.10).aspx and http://www.visguy.com/2007/05/11/integrating-visio-2007-with-microsoft-technologies/  for starters.  In the program, you'll have to read and parse the descriptions to extract necessary number/type of pins.  There is no sizing info, so you'll have decide on a standard (grid size, input/output pin lengths, etc.)

How are you planning to interconnect the symbols--manually or automatically?  Once connected, is a pretty picture all you need, or do you need a netlist, and if so, what will the netlist be used for?  For example, how do you know you've connected the symbols correctly?  There are other, better suited programs for netlisting, design verification, simulation, and layout generation than Visio.  (Also, much more expensive.)  These are typically complete packages, beginning to end, of the design process.  However, regardless of the path, you'll need to create your custom symbols or adapt existing (extensive) library symbols.

Wapperdude

Visio 2019 Pro

Paul Herber

As Wapperdude says, if all your examples are exactly like your pasted code then decoding will be quite easy, if the only variants are the names of the two inputs and the one output.
The more the text to be decoded varies from your example then the more difficult will become the task. If only the number of inputs/outputs can vary then you have to determine that and place the inputs and outputs on the shape appropriately.
Any other differences will have to determined, a robust error handler can detect these differences, but that all depends upon what the differences are and on how many shapes you have to handle. If there are only 10 then a quick manual check may determine whether the shapes have been created correctly, if there are hundreds or more then you will have to ensure that your program tells you if there is any chance that the shape may not be what is wanted. Failing silently is probably not an option.

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

flow3rgirlz

Thanks for the reply.

I'm just curious is there any sample program which draw any drawing and save it as master in stencil?