Serialized Printing Method - linux

I am looking for a method by which I can print one document, and have a field that is incremented on each copy printed. I currently run linux, so bash in concert with several programs might be the way to go, but I'm just not sure where to start.
I have a document that is used for our business that currently is hand stamped for serialization... We would like to simply print them but cant find a method by which to increment a specific field. I would like to use either a PDF or an ODF/ODT for the document.
Thanks for any help you can give!

How is the document produced at the first place?
If you master that process, you could certainly add serialization at that level. For instance if using LibreOffice you could do that in LibreOffice. If using a text formatter (like LaTeX, Lout, ....) just emit the formatting instructions (e.g. the .tex or .lout source file) with some unique counting (perhaps simpler to do in some scripting language like Python or Ocaml).
Then run the relevant tool to get a .pdf file.

Related

Can Python make tracked changes

I'm quite new to programming. I recently took an online course in Python 3. I previously wrote an extensive macro in Word VBA that I would like to translate into Python and then develop into an executable program that would open a selected Word document and apply various changes mainly based on find and replace functions.
It's critical that all the changes would be accurately tracked (including formatting changes). Additionally, the software must trigger the acceptance of any existing tracked changes in the document before applying further changes.
Is it possible to do this using Python? Ideally the program should open a Word document, run the specified find/replace functions, save the document as a new file, and then trigger the combine documents function of Word to generate a final file containing all the tracked changes.
I've read through the documentation for the Python Docx module and can't find the answer there or in previous stack overflow questions.
I'm grateful for any help.
You need to look at the win32com api for python. This will allow VSTO type control of Office components.
Chapter 7 of Wesly Chun's Core Python Applications Programming (Third edition) will give you a basic grounding.

Is it possible to keep a variable active with Revit Python Shell, using canned commands?

I'm currently using Revit Python Shell 2017 and I'd like let's say to make "communicate" different canned commands.
For instance, let's say I load a house model, and I create some additional walls on it, via a canned command that I would have previously created. While creating these walls, I could store all these new walls IDs in a variable, as a list.
Now, if I want to delete exactly these walls afterwards, I'd like to identify them using their IDs that I stored in the list, then delete them.
If I was in an interactive Python Shell session, well the "IDs list" variable would still be accessible (as long as I don't close the shell), and I could just retrieve the IDs from it, then delete the walls.
But what if I'm using canned commands? The first command would be "create the walls", and the 2nd would be "erase these walls". But that "IDs list" variable doesn't exists in the second canned command environment, so that I can't use it to erase the walls.
So, what would be the approach? Of course in this example I could identify the walls in the second command using a different methodology, such as asking the user to select them etc etc.. But the idea I'm going for would be the store that list from the first command "somewhere in Revit", and retrieve it when calling the second command.
I could write the list to an external text file, and read the file in the second command... but is there a cleaner way?
I'm sorry for the beginner's language used here, and hope that my question is clear enough! And that somebody can help ;)
Best,
Arnaud.
This is a great question Arnaud, in the past Ive done the following:
Create a text project parameter, and populate it with XML (yes you can have line breaks in a text parameter). This is similar to what Ideate BIM Link does (check the project parameters of any project that has used BIM Link). This is a long-winded method for keeping data persistent between commands.
The second part (saving a walls IDs) is more difficult I think, as I understand it every time you open a project the IDs are reassigned. You could test this to see if its the case?
Another method could involve using an External command that lingers after you have finished selecting walls. Could you go into a little more info about what youre wanting to achieve?
So,
Just for leaving a trace, I solved this using pyRevit and its ability to store data in temporary files (here, look for "Using Temporary Files").

CSV to Excel Doc?

I was curious what the community thinks is the easiest way to take a CSV file and 'save as' a Excel document with only a couple formulas pasted in?
I am trying to do this behind the scenes, and not physically navigating. e.g. opening, selecting save As, etc -- even though this is already VERY simple I **need to do this in code (Think automation)
Background: I have a c++ command line program generating the .csv, and a C# GUI starting this process. Either programs could hold the code, but I figure this is easiest in C# (InterOp?) The reasons I don't directly send code into the csv is because of the amount of comma characters that will mess up the csv and because other Excel documents need to reference the sheets so they need to be in .xls format.
=AVERAGE(C2:C999)
=COUNTIFS(C:C,">0",C:C,"<31")
=COUNTIFS(C:C,">31",C:C,"<55")
=COUNTIF(C:C,">55")
Have a look and see whether command-line scipting of openoffice will do the job. It can do quite a lot of conversions very easily. Otherwise there are a lot of Excel-producing libraries, for example PHPExcel, but you'd need to wrap some programming around them.

Using different program office extension

I have a program that can access a database with a whole bunch of articles.
Due to copyright, I can't access the database straight from my program, but I have a different program that can access it, and it's legitimate to copy small bits from the articles.
Because my friends and I quote a lot from these articles, I thought it would be useful if we could find an add-in for Word that will copy the requested part from an article.
Is there any add-in for Word that would let me use the program that I mentioned above so that I can access the database from within Word?
I would like to program this add-in myself, if possible.
Without further information about which operating system, and version of Word you are using, I can offer only a general outline.
1) It seems to me that you want to make a Word macro using Word Basic, or Visual Basic.
2) When you want to call your program which is external to Word, you need to use the shell command as outlined here from Microsoft's webpage.
I hope that helps you get started writing your macro!
CHEERS
Well its a wrokaround but you can use an automation tool which can run a sequence of actions on a given GUI like Winrunner or TestQuest to semulate the usage of the program, i assume these tools can get an input from a given xml or text file and log outputs in log text file.
If you have the output in a text file you will be able to parse the file using any programmign language and get the information you need and write it to eord or whatever format using OLE objects.

I want to change the way text is represented internally in ANY Text Editor

I want to use a algorithm to reduce memory used to save the particular text file.I don't really know how text is stored but i have an idea in mind.
Would it be better to extend a open source text editor (if yes than which one) or write a text editor myself.
It would be nice if someone could also give me a link or tutorial to some basics on how text editors work and the way data is stored.
Edited to add
To clarify, what I wanted to do is instead of saving duplicates of a word make a hash table and store the address where it needs to be placed.
That way I wouldn't be storing the duplicates.
This would have become specific to a particular text editor.
Update
thanks everyone I got what all of you'll are trying to say. Anyways all i wanted to do is instead of saving duplicates of a word make a hash table and store the address where it needs to be placed.
This was i wouldn't be storing the duplicates.
Yes and this would have become specific to a particular text editor. never realized that.
I want to use a algorithm to reduce memory used to save the particular text file
If you did this you would no longer have a text editor, but instead you would have created some sort of binary file editor.
The whole point of the text file format is that it is universal, meaning any text file can be open in any other text editor.
Emacs handles compression transparently. Just create a text file with .gz extension. Emacs will automatically compress contents of the file during save operation, and decompress when you open the file next time.
Text is basically stored as-is. i.e., every character takes up a byte or two (wide chars), and there is no conversion done on it when it's saved. It might add an end-of-file character or something though. Don't try coming up with your own algorithm to compress these files. That's why zip-files and other archives were created. They're really good at compressing text. If you wanted to add these feature to your text-editor, you'd have to add some sort of post-save hook to zip it, and then put a hook on the open command to unzip it. Unless you wanted to do it by hand every time. Don't try writing the text editor yourself from scratch, unless (maybe) you're writing notepad. Text editors with syntax highlighting aren't very easy to make, even with the proper libraries. I'd say write a plugin for something like Visual Studio or what have you. Or find an open-source text editor.

Resources