I'm developing an automatic documentation application in Python. One of the required features is to draw flowcharts. As the users use Visio, I would like to generate the flowcharts in Visio format, so the user can make fine adjustments in the drawing without having programming skills. I'm searching by VSTO Add-ins for Office, and while it looks possible to be used to make Visio drawings programmatically, it's not clear if it's possible to use it with my Python application. Would it be possible to use Python to send information to a VSTO Add-in and use it to draw a flowchart in Visio based on this information? How this can be implemented? Is there any other recommendation of how to generate a flowchart programmatically in a format that users can edit using a vector graphics editor?
There is no need to communicate with a VSTO based add-in. You can automate any MS Office application (including Visio) from a Python script. I believe pywin32 can help with such tasks.
from win32com.client import constants
appVisio = win32com.client.Dispatch("Visio.Application")
appVisio.Visible =1
doc = appVisio.Documents.Add("Basic Diagram.vst")
pagObj = doc.Pages.Item(1)
doc.SaveAs(r'e:\temp\MyDrawing.vsd')
doc.Close()
win32com gives you back a thin Python wrapper around a COM server provided by the application. The documentation for the Visio object model is here.
Be aware that the objects you get back are COM objects in a thin Python wrapper and so don't always behave like Python objects, and the documentation assumes you are writing in VBA not Python.
Related
I'm currently developing a Django app that allows students to programmatically develop SVG graphics. They can code Python in their browser with ACE editor. The code is executed on the server, stored in a database and the generated SVG (custom library) returned and displayed. An example code that displays a filled ellipse looks like so:
graph.draw(Circle(cx=0, cy=0, r=20, fill="lime").scale(2, 1)
Now I'm wondering, how I could extend this app to do some 3D. I stumbled over X3Dom, which seems promising and not too hard to generate and I could write another lightweight pythonic library for this. But, it doesn't seem to do CSG (constructive solid geometry) which is major drawback.
Any hints in what direction I should investigate for some 3D web technology that allows easy 3D scene generation with server-side python and that implements CSG?
NB: OpenJSCad is simalar to what I'd like to achieve, except that my solution allows for classroom collaboration and it must expose Python to students as the programming language. The aim is to spice up the teaching of Python programming with graphics.
I believe I used three.js to do CSG a while back. There used to be an example online. You are right that X3D does not do CSG. I was doing cross sections of the earth and found a way with X3D. You might be able to use VPython or brython in the browser if your worried about Python not running in the browser. I’ve only brython for a short time testing another person’s project and vpython not at all.
If you’re doing something like inverseCSG or CSGNet, is your class available online?
In other words, maybe try to find a Python library that does CSG instead searching for a rendering engine in JS. Don’t view the browser as limited to JS.
I only found three.js when I was looking.
Maybe search for a solution which is not a solid solution.
try checking out the library "trimesh" for python which relays mainly on watertight stl files, but allows you to do some boolean operations for CSG. You can substract one file from the other, extended and find the intersection. Plus, it has some primitive functions directly like cylinders and spheres.
I want to create a piece of software that allows me to create manipulable diagrams (state machine alike) in python. What library should I use (does at least one exist)?
I found this js library (https://gojs.net/latest/samples/stateChart.html), but I'd like to create the whole program in python.
I did not found something that lets you work with diagrams from the UI standpoint.
I would like to be able to click on a certain diagram and edit its contents and manipulate the contests of all diagram objects.
Use pysimpleautomata library pysimpleautomata
You might have to create your own api to create interface though. For that, I'd suggest using tkinter.
At the moment I have to develop some python tools, because nearly every software I use (QGIS, FreeCAD, Gimp, probably my toothbrush ...) has a python interface.
I would like to write lazarus applications (with button, edits and all the nice components), that uses my python routines in the background and show the results in lazarus.
Is there a way?
Here's an example at the Lazarus forum how to use the Python for Lazarus package. From Lazarus Online Package Manager it installs automatically.
https://forum.lazarus.freepascal.org/index.php/topic,43557.msg305118.html#msg305118
Set PythonEngine.IO to PythonGUIInputOutput, then choose a control for PythonGUIInputOutput.Output to show data and your good to go.
You could try to use
https://github.com/pyscripter/python4delphi
that is a binding between the two.
There is also always available the possibility of implementing a web server with python and publish its services on http for use from lazarus.
Note however that if what you want is a GUI then Qt (using PyQt or PySide) is a very complete GUI library with a very good binding for Python... it has all the widgets you can imagine, and then some more.
In that case all the code you write is in Python.
We are using software called Enovia.
I would like to query Enovia from inside Excel / VBA.
After some search, Enovia seems to have a programming interface called Abaqus.
http://www.3ds.com/products-services/simulia/services/training-courses/course-descriptions/introduction-to-the-abaqus-scripting-interface/
I would like to access this interface in VBA directly but I didn't find anything to that effect.
I found two projects that might allow Excel/VBA to talk to python components or at least to python scripts.
They are as follows
Python For Excel
http://opentradingsystem.com/PythonForExcel/main.html
And the discontinued excelpython
github.com/ericremoreynolds/excelpython
which became integrated in xlwings
xlwings.org
I am not familiar with python nor these two projects. I'm not sure if they will allow me to do what I want.
I'm ok with learning some python to do this but my main program and user interface is in excel.
I figure I could make some simple python scripts then call them through the python interpreter from excel with shellexecute but that is not a very elegant solution I think.
Any advice welcomed
thanks !
Enovia uses the MQL language for scripting. There are some guides available, such as http://emdros.org/MQL-Programmers-Guide.pdf
I would recommend some training such as http://www.techniatranscat.com/services/education/mql-and-tcl-intro as this doesnt seem to be a very common language.
Not to be confused with the financial trading language MQL4/MQL5 from MetaQuotes Software Corp.
ENOVIA does not have a Python programming interface.
Abaqus is a FEA simulation software which can be scripted with its own Python programming interface.
ENOVIA though, is a PLM software solution. They are different software for completely different applications. As programming interfaces you may look at maybe this
In short, you may need to contact your Dassault Systemes local support team to point you in the right direction.
Using tcl and mql you can solve the problem
TCL |
MQL
Latest Enovia version 3DEXPERIENCE support Rest based webservices. you can create a rest API in enovia and can call rest service using vb script in excel.
3DEXPERIENCE Enovia Rest webservice Framework
Above mentioned Rest framework may not be available with 2014X version. You have to try SOAP based service or JAX-RS.
Option 1
Enovia is java based application and doesn't support VBA ADK to directly work with backend data. However webservice can be used communicate between applications of different platforms or managed by different programming ADK.
For this you need to create your own service (REST/SOAP). For this you will need server access and first you have to write some java code (Rest/SOAP service) and update the class/jar into 2014 server (tomcat).
Then you can make use of that service in to your vba function.
Again you have to decide the kind of data whether xml or json it is separate topic.
Option 2
As I told earlier Enovia is Java based application, It provides JAVA ADK to extend its functionality.
Sample code shows how you can get the context and work with Enovia ADK.
matrix.db.Context ctx = new matrix.db.Context("http://myserver-nocas:8080/enovia");
ctx.setUser("Test Everything");
ctx.setPassword("");
ctx.connect();
System.out.println("Is context set "+ctx.isConnected());
As you mentioned you are currently using 3DEXPERIENCE then 3DPassport might block above URL method connection, So you need to pass NO-CAS URL.
You can get the context by running above java code from your local eclipse. Using this ADK you can also call MQL queries and work seamlessly.
import com.matrixone.apps.domain.util.MqlUtil;
String strPartFamily = MqlUtil.mqlCommand(ctx,"temp query bus Part * * select attribute[Length]");
But again this is java based solution and not VBA.
Finally 3DEXPERIENCE provides MQL console in server, to play around with all the data using SQL like queries in more developer friendly manner. Enovia also provides web based MQL console but you need to have some license for that (Administrator should be having access).
Use TCL to go through Excel sheet, it is very easy. Use "/t" to separate data.
I was searching for a Python piece of code which would simulate keystrokes.
I stumble upon something using win32com.client.Dispatch("WScript.Shell").
I am not fan (at all) of Windows but it is to help a friend with automation of a game.
I got a problem, this works fine on notepad or firefox for example, it does write but not on his game.
In order to find wether it comes from his game or my automation I would like to have some details about win32com.client and what really represents WScript.Shell
Thank you all
Some citations:
As we discussed previously, automation objects are COM objects that
expose methods and properties using the IDispatch interface. So how do
we use these objects from Python? The win32com.client package contains
a number of modules to provide access to automation objects. This
package supports both late and early bindings, as we will discuss.
To use an IDispatch-based COM object, use the method
win32com.client.Dispatch(). This method takes as its first parameter
the ProgID or CLSID of the object you wish to create. If you read the
documentation for Microsoft Excel, you'll find the ProgID for Excel is
Excel.Application, so to create an object that interfaces to Excel,
use the following code:
import win32com.client
xl = win32com.client.Dispatch("Excel.Application")
(from this)
The WScript.Shell object provides functions to read system information
and environment variables, work with the registry and manage
shortcuts.
(from: 1 2)