Is it possible to continue working in Revit while running a python script in pyrevit? - revit-api

When running Revitpythonshell or running a python script with XAML gui I am unable to work in Revit until closing Revitpythonshell or the python gui.
Is there a way to keep Revit from becoming inaccessible like this?
I would like to keep my script open to continually use while I work.

You have a couple of options here depending on what your script is trying to do:
pyRevit has a 'non-modal' console that keeps Revit accessible.
Pythons threading module could be what youre looking for. You can automate alot of tasks in the background as you continue working, with one big caveat: Revit is a single-core program, so if you touch the database / API from another thread - Revit will crash.
You can start a process on a thread, then close the console. Your thread will continue to run - you just have to use winforms or another UI tool to let you know where the thread is up to. I use this to automate non-Database tasks that take 30-45 mins, while continuing to work in Revit.
If you need to keep accessing the Revit Database / API from your script, Id recommend making a simple UI and get it talking to an ExternalEvent in Revit. Here is a fantastic example of using a form with ExternalEvent by Cyril Waechter: pyRevit WPF non-modal trouble

Related

How to schedule a task in Node.js that runs after script has exited?

In writing an Electron app, I've found the need to execute a background task that will run even when the UI has exited. An installer will be distributed to different computers, so I need a way to schedule a recurring task either in the installer or in code that gets run as part of the Electron app process. I've looked into libraries like bree and agenda, but I haven't been able to find a way to schedule in the aforementioned manner with these libraries.
How would I a) extend the functionality of the installer to schedule the task with native tools like Windows Task Scheduler or b) schedule this sort of recurrent task from my Electron app?
if you want to change the installer, then you need to investigate custom pages in NSH language to inbuild this functionality into electron-builder installer
this will be complicated
In my work I faced similar need and set a recurring task via windows scheduler tasks just by running a process command, please have a look at my code here:
https://github.com/beliaev-maksim/beta_build_downloader/blob/6b5fce4b675cc108e4048e7d65676133df0ef78e/electron_ui/js/tasks_handler.js#L61
same could be achieved using cron on Linux systems (but have to be installed on some distributions)
Do not forget to vote for the answer and mark as accepted if that helped you

How to make a python application distributable

My question pertains to distributing a python application the proper way. i have done research, but the answers appear to be vague and usually instruct the user to upload projects to the python package index. I simply want to make sure i research the proper methods instead of steering in the wrong direction.
I have been writing a stock analysis application with stored text files, and a dozen or so python scripts that interact with each other. Outside computers are to communicate with my servers through a random port (not the internet ports). all the imports work properly and the communication works properly, but i have no clue how to approach the distribution/setup or the GUI.
As an application with dozens of python scripts, should i write each script as an executable via pyInstaller, or should i add a python environment to the application to install python on all the user systems?
I need to add 'README', and 'LICENSE' to the application. What is the point of set up? is that a resource so python knows what is going on or does it actually setup the application? Does it need a URL, and what is the point of using the URL? Do i need anything else for the setup tools?
How do i package the entire application to download on user systems? I want the software to be uploaded via a URL link or from a USB. Do i have to make a tar file? i can do it automatically by writing my own python setup script, but i believe python has an easier way. Do i put a function in the setup to send an executable file to the desktop as a controller so the users don't open all the folders? How do i install from a link on a website?
For a graphical interface for the users on python applications, do most programmers use tkinter, or python integration into HTML, CSS? I do not want this application to be live in a website, but rather as a desktop application. Do i need to use a framework, such as django, to implement python into my html code?
I apologize if this is all unorganized. Ive always coded my own programs and never distributed or put a GUI on any of the scripts, so i just want to make sure i approach the task the right way.

NightmareJS without closing the browser

I'm used to PhantomJS and Watir, which both provide a REPL out of the box. The REPL lets me execute automation calls on a currently-running browser.
This is a fun way to make automation scripts because I can watch the effect of each step as I build an automation script.
In fact, I can even write a script that defines methods for opening a browser, performing a log-in, and other common tasks, and then call them as I please from within the generic Node or Ruby REPL.
Can I execute NightmareJS calls without closing the browser (Electron)?
Without closing? Yes - don't call .end().
If you're asking if you could disconnect the IPC - meaning the calling program ends but does not end the Nightmare instance - and then pick up the Nightmare instance again somewhere else, the answer is no.
#393 (packaging Nightmare functions with an existing Electron application) and #593 (covering v3 wants, including one Electron instance for many applications) are related, but I'm not convinced attaching IPC from new calling applications is a great idea.
If you provide more information about what your circumstances are and what you're trying to do, I'll edit this answer to try to help.
Having a REPL is a different question - I will add it to my list of things to look into. It's a good idea.

include C++ application in firebreath

I have created a C++ application using Pjsip Stack and my next step to create a plug-in,for which i am using firebreath. Being a newbee, I dont have any idea of including my C++ project in Firebreath application. Although I searched many links for over a week and tried stuff on my own, I couldnt come up with solution to my problem.
If I can get any guidance for the same I'll be grateful.
The first step is to learn how to write a firebreath plugin, which you can do by going to http://firebreath.org and following the tutorials. You need to keep a few things in mind, though:
Plugins have a different lifecycle than applications.
They start when the browser says and have to go away when the browser says and they can't block the main thread.
They run in a process that they don't own.
Global variables are shared between all instances of the plugin
There could be any number of said instances
Things like the current working directory should probably be left alone.
Turning an application into a plugin is more a process of porting than it is of embedding, and how hard it is depends on how well the application is written; remember that your plugin could be instantiated and destroyed many times before the process is unloaded, so if you have memory leaks it can be a major problem.
The main thing, though, as I said earlier, is just to learn how to write a firebreath plugin. You can best start that by looking at the examples in the repo (particularly fbtestplugin) and following the tutorial to create a new project, then just play until you figure it out. There is an IRC chat room and a google group where you can get help.

Are there any Node.JS IDE's that are REPL interactive and mainstain state like the node.js console does?

I'm looking for an IDE or environment, or "graphical console" similar to ISE for PowerShell.
I want to work on some JavaScript but not have a new instance of a node runtime everytime. Just like in the console I want to be able to run some code here and there, and still have access to the variables from commands I ran a few minutes ago. Also i'd love one that also can take the JavaScript Objects or JSON and display them visually rather than just in plain text like the console does.
Is there any IDE for this sort of thing, or are all the Node environments build for starting a new Node instance everytime you run your solution?
I'm not a Javascript programmer, so I don't know exactly if this is what you are looking for, but you might check out Cloud9 IDE. It's web-based, supports Node.js, and saves the exact state of your setup so you wouldn't need to restart anything every time you log in.

Resources