Embedding a Calculation Tool inside AutoCAD Plugin — Experiences & Best Practices?

Embedding a Calculation Tool inside AutoCAD Plugin — Experiences & Best Practices?

robertlewis00980
Community Visitor Community Visitor
460 Views
3 Replies
Message 1 of 4

Embedding a Calculation Tool inside AutoCAD Plugin — Experiences & Best Practices?

robertlewis00980
Community Visitor
Community Visitor

Hi everyone,

 

I’m working on a plugin for AutoCAD that helps professionals estimate certain financial data right from within their CAD environment — for example, a gratuity / end-of-service benefit calculator (say, for UAE contracts). I want it to be lightweight, reliable, and easy to maintain.

 

Some of the architecture ideas and hurdles I’m facing:

 

Whether to host the calculation logic externally (REST API) or embed core logic locally in the plugin.

 

How to manage versioning: if the calculation rules change (due to labor law updates), I need to push updates without breaking existing installations.

 

Handling input validation (dates, years, salaries) robustly inside plugin UI so it doesn’t crash or miscalculate.

 

Performance: too many calls or heavy computation might slow down AutoCAD — how to optimize this (caching, prefetching, multiplexing)?

 

UI integration: how to embed a small calculator panel or dialog inside AutoCAD workflows so it feels native and unobtrusive.

 

 

If anyone has built something similar — calculation tools inside CAD plugins or lightweight embedded utilities — I’d love to hear your experiences, pitfalls, or code patterns you found useful.

 

Thanks in advance for your help — I’m eager to get ideas from seasoned AutoCAD developers. 😊

0 Likes
461 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

Some thoughts:

 

"Whether to host the calculation logic externally (REST API) or embed core logic locally in the plugin."

 

It would depend on whether the calculation has anything to do with AutoCAD/drafting process (other than the CAD user's inputs that may require the user looking at the AutoCAD editor for some information, or need to run some code to collect CAD data as input for the calculation. It also depends on whether the calculation is used/shared by other business operations. But based on what you described in following question, it seems the calculation would need other data outside data, it sounds that it would be better to have the calculation logic done outside the AutoCAD. But, event the calculation needs data not related to drawing data in AutoCAD session, but it is only needed by CAD user when AutoCAD running (no other business processes need to access the calculation, then you might make thing simple by do it all in the Acad plugin (save you effort to create a separate service layer app running all the time to wait a calculation request).

 

"Performance: too many calls or heavy computation might slow down AutoCAD — how to optimize this (caching, prefetching, multiplexing)?"

 

Does the calculation takes time/consume computer resource heavily? If the calculation runs in the plugin, does it need to interact with AutoCAD in some ways, such as collecting data from drawing (including user interaction with ACAD), do some calculating, collecting data again, calculating again, ... If the calculation is done outside AutoCAD (a service app AutoCAD is connected to when needed), then the performance would only be impacted depending on how the calculation is triggered. If it is started by user interaction (start command, input data vis possible UI, and then click button "OK/Calculate", I do not see how it slow down AutoCAD - when user does this, AutoCAD is idle, right?

 

I'd say that the most important question you need to answer how much the calculation operation is related/dependent on AutoCAD. Or, it is only these particular CAD users need this calculation, while the calculation itself is hardly depending on data from running AutoCAD session, only only need to collect some data in AutoCAD session before the calculation.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

daniel_cadext
Advisor
Advisor

You could use a palette for your GUI, then all your non-CAD related stuff could be in background threads.

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 4 of 4

engrjvb
Advocate
Advocate

Just a question, if you are creating a calculator and it does not have anything to do with AutoCAD entities but financial figures, why not just create an executable file and create a function or button in CAD to call it?

Automation is to your time as compound interest is to your money
0 Likes