CEXT-Dan / PyRx

Python for AutoCAD
47 stars 7 forks source link

CAD bundle installer #73

Closed gswifort closed 4 months ago

gswifort commented 4 months ago

I think the best solution would be to change the approach to installation. The project can be hosted on PyPI so that it can be installed using pip install. After installing the package, we would have access to modules written in Python, the installation could be global or in a virtual environment. The Bin folder would be downloaded together with the python modules, and after executing the command, e.g. python -m pyrx bundle install, the Bin directory would be copied to %localappdata%/... (i.e. it would do the same thing as the .msi installer does now ). A similar approach is used in the xlwings project, where using xlwings addin install the excel addin is installed. We would further use what we obtained in #1, if Cad was launched from the virtual environment, it would have access to the pyrx library (pure python) from the virtual environment, and if not, the packages found on the basis of PyRx.ini would be used. In the module loaded with PYLOAD we would then have:

from pyrx.tools import get_objects

ActiveX modules can also be moved:

from pyrx import AxApp25 as Ax

I think eventually stubs should also be included in the pyrx library, we need to refer to PEP 561

Originally posted by @gswifort in https://github.com/CEXT-Dan/PyRx/discussions/67#discussioncomment-9687805

gswifort commented 4 months ago

For the installer to make sense, you would need to store the Bin directory in the repository (and not just as a .zip file in releases). There is no need to add it for now, maybe only after the installer is developed, but I would like to know if you see any contraindications.

CEXT-Dan commented 4 months ago

That’s fine, I’ll set Visual Studio to copy the output into that folder

gswifort commented 4 months ago

The PyRx extension can be detected by adding a directory with the appropriate structure: %appdata%\Autodesk\ApplicationPlugins\PyRx.bundle\ As I understand it, this is not possible with clones? User needs to load .zrx, .grx and .brx manually?

CEXT-Dan commented 4 months ago

That’s correct, however the clones support auto-loading via the registry. I refrained from doing this because of the baggage associated with this, may require elevated privileges, uninstall mechanism to remove the entries

In theory, there could be a reg script, something like

[HKEY_CURRENT_USER\SOFTWARE\Autodesk\AutoCAD\R24.3\ACAD-7101:409\Applications\PyRx]
"DESCRIPTION"="PyRx"
"LOADCTRLS"=dword:0000000d
"LOADER"="M:\\Dev\\Projects\\PyRxGit\\Bin\\RxLoader24.3.arx"

might be a can of worms because we don't know if the target app is installed

gswifort commented 4 months ago

Higher permissions will not be required for the HKEY_CURRENT_USER section. With python, installing and uninstalling should be relatively simple. We can probably deduce whether a given application is installed based on the existence of the main entry, e.g. HKEY_CURRENT_USER\SOFTWARE\Autodesk\AutoCAD LT. I can deduce the registry structure for ZWCAD based on other entries, but I can't find documentation on this subject - do you know where I can look?

CEXT-Dan commented 4 months ago

There’s none for the clones, AutoCAD has some here https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-1C2DC8E6-B2CF-42CE-9D5B-238AF77C0D1C

I’ve never done autoloading for Zw or GStar. OpenDCL installs for everything under the sun. I was considering taking inspiration from Owen’s code https://sourceforge.net/p/opendcl/code/HEAD/tree/Trunk/Runtime/RxInstall/RxInstall.cpp

BricsCAD has side by side support loading for different locales, so it gets more complex. I don’t know how this is handled with ZwCAD I have support requests into the clones for supporting bundles