This post was updated on .
Hi everybody,
I want to create a plugin which allow to export to pdf several A4 of a drawing first: I had created a drawing dxf and a file txt which indicate for each pdf file: name, A4, Landscape or portrait, poistion X & Y of each file in my drawing, the ration 1:1 and the unit of my drawing With my plugin, I can open the file txt and read it and extract each value My problem is to know how to call each class like print preview, export to pdf, etc.. thank's a lot for your help. Regards |
Administrator
|
Welcome Ludovic,
I'm afraid that the plugin system don't supply what you need. Take a look at librecad/src/plugins/document_interface.h This class is the interface for plugins to modify a drawing document. You can add, delete and modify entities in the current drawing, but you don't have access to core application functions. I suppose, that what you try to achieve, could only be done from inside the application. What I can imagine, how it may work, is a command line functionality. Like calling librecad executable with command line parameters (DXF and TXT file names or a parameter list instead of TXT file) and then do the PDF export and exit without starting he GUI. This way it would be possible to call the application from batch file to do multiple conversions. Iirc, similar functionality was requested a couple times, but nobody battled this yet. Armin
investing less than half an hour into Search function can save hours or days of waiting for a solution
|
Thank's for your answer.
I had already have a look to the document_interface.h I had succed to call an "addline" routine for exemple. But this interface doesn't have the classes I need. I also had a look to the command Lines in the GUI; idem. Your idea may be very interresting, but I think it's to difficult for me In fact, I have more than 200 pdf to export; manually is very long. Ludovic |
I have automated similar tasks for other cad software (on windows) using http://www.sikuli.org/
It is a quick workaround for automating repetitive work that can't be scripted inside the program or involve multiple programs to work together. Instead of using the sikuli visual interface with pretty pictures as function parameters I installed python (I used the "canopy" install package in windows) and call the same sikuli functions directly from python, with PNG filenames as parameters. then make a print-screen of all the buttons you need to open a file, open the print dialogue, change print settings, etc. Then make a python program that is mostly a sequence of clickt-the-middel-of-this-button, wait 0.5 second, clickt-the-middel-of-this-button, wait 0.5 second, etc. You can add an offset to click at some position relative (outside) an image, to click on the field where you can enter the filename you want to open. Then make a python array with all the files you want to open/print, and use a sikuli function to simulate typing each filename after simulating the click on the filename field. The nice thing of using python instead of the sikuli interface is that you can make functions like open_file(filename) that contain a sequence of button clicks and simulated filename typing to make neat python functions for specific tasks that can then be used to do more complex tasks. For example, I have functions for opening one cad program (by simulating a double-click on the program icon on the windows desktop), opening a file, exporting it in some file format, closing the cad program, starting another cad program, importing the exported file, and doing something with it, then repeat 150 times. there are also functions to wait for a specific image (or image of a piece of text, like "ready") to appear and you can send menu shortcut keycodes instead of making print-screen images of menu names is the program supports key shortcuts. I use a 2-screen setup to have the cad program on one screen and python on the other so it does not block the view of the cad program. I have even used it to automate tasks on a remote computer by sharing the desktop screen via internet. sikuli has a tolerance for image similarity so it works even if the screen image is compressed. If you want to try this and think you can get python and sikuli installed, I can lookup some script examples. |
Thank's a lot
it's a very interresting way to solve my problem. Let me a moment to have a look at this Ludovic |
I posted an old script (may not be complete or relevant, but you get the idea) especially note the "from lackey import *" and "wait_and_click()" function: https://pastebin.com/0CHHQRuJ
I'm off-line for the following hours, but back later today. |
Sikuli is very interresting.
Here are my files The aim is to convert to A4 pdf all panels in sections 1.3 & 1.4 of the dxf file. All panels to be convert are listed in the txt file. The only thing I don't succed is to place my A4 format on the drawing at the point listed in the txt file. Librecad difine this point with the course of the mouse; but we cannot it write explicitaly. I suppose I must do without coming into the display mode. Here are my files LEP-2D_LG.dxf PRINT-LG.txt |
I have done tricks like that in autocad by doing window-zoom with the script entering the zoom coordinates, so I know the point I want in the centre of the drawing area, and can click there. I can't enter coordinates in the librecad window-zoom, but maybe you could draw a very large circle at the location you want, then click auto-zoom, then zoom in a couple of times, then click the centre of the drawing area. (just make an image of the top-left corner of the drawing area, and add an x and y offset to the mouse click)
|
Free forum by Nabble | Edit this page |