Tehisaru joonestuslaua taga: Claude juhib DraftSighti ja Fusionit
AI at the drawing board: Claude driving DraftSight and Fusion
Tahtsin teada, kas keelemudel suudab päriselt CAD-programmi juhtida: joonistada, mõõta ja mudelit üles ehitada. Proovisin kahte teed: DraftSighti jaoks ehitasin ise C#-is vahelüli, Fusionis on see juba sisse ehitatud. Mõlemad töötasid. Huvitavam oli aga aru saada, milleks see tegelikult sobib ja milleks mitte.
I wanted to know whether a language model can really drive a CAD program: draw, measure and build up a model. I tried two routes — for DraftSight I built my own C# bridge, in Fusion it is built in. Both worked. The more interesting part was understanding what it is actually good for, and what not.
Kaks teed
Two routes
MCP (Model Context Protocol) on viis, kuidas keelemudel saab teise programmi tööriistu kasutada. CAD-programmi puhul tähendab see, et mudel saab joonistada, mõõta ja joonist lugeda. Tavalise eestikeelse käsu taga on päris API-kutsed.
MCP (Model Context Protocol) is how a language model uses another program’s tools. For a CAD program it means the model can draw, measure and read the drawing — behind a plain-language request are real API calls.
DraftSight: C# API ja oma MCP-server
DraftSight: C# API and your own MCP server
DraftSightil on C# API, aga mitte igas paketis. Esimene samm on kontrollida, kas installatsioonis on kaust APISDK ja selles DraftSight.Interop.dsAutomation.dll. Kui seda pole, saab selle paigaldusprogrammist juurde lisada, kui litsents API-t lubab. Uuemates versioonides kuulub API ainult kallimatesse pakettidesse.
DraftSight has a C# API, but not in every edition. The first step is to check whether the installation has an APISDK folder with DraftSight.Interop.dsAutomation.dll. If not, it can be added from the installer when the licence includes the API. In current versions the API is only in the higher editions.
Esimene test võtab umbes 15 minutit: väike konsoolirakendus haagib end töötava DraftSighti külge ja joonistab joone ja ringi. Kui need joonisele ilmuvad, API töötab.
The first test takes about 15 minutes: a small console app attaches to the running DraftSight and draws a line and a circle. If they appear in the drawing, the API works.
// esimene test: kas API töötab? (.NET Framework 4.8, viide dsAutomation.dll-ile)
var app = (Application)Marshal.GetActiveObject("DraftSight.Application");
app.AbortRunningCommand();
SketchManager sm = app.GetActiveDocument().GetModel().GetSketchManager();
sm.InsertLine(0, 0, 0, 1000, 2100, 0); // mm
sm.InsertCircle(500, 1050, 0, 100);
// first test: does the API work? (.NET Framework 4.8, reference dsAutomation.dll)
var app = (Application)Marshal.GetActiveObject("DraftSight.Application");
app.AbortRunningCommand();
SketchManager sm = app.GetActiveDocument().GetModel().GetSketchManager();
sm.InsertLine(0, 0, 0, 1000, 2100, 0); // mm
sm.InsertCircle(500, 1050, 0, 100);
Sealt edasi on MCP-server väike .NET-rakendus (NuGet-pakett ModelContextProtocol), mis annab Claude’ile tööriistad nagu „joonista joon“ või „loe aktiivse joonise andmed“ ja kutsub nende sees sama API-t. Proof of concept töötas: Claude joonistas DraftSightis tavalise käsu peale.
From there, the MCP server is a small .NET app (NuGet package ModelContextProtocol) that gives Claude tools like “draw a line” or “read the active drawing” and calls the same API inside them. The proof of concept worked: Claude drew in DraftSight from a plain request.
COM töötab ainult samas arvutis. MCP-server peab jooksma DraftSightiga samas masinas ja kõige lihtsam on, kui ka Claude töötab seal.
COM only works on the same machine. The MCP server has to run on the DraftSight PC — simplest if Claude runs there too.
- Kõige kiirem viis API-t õppida on makro salvestamine: joonista käsitsi ja loe genereeritud koodi.
- Interop-DLL näitab täpselt, mis sinu versioonis olemas on (Visual Studio Object Browser). Anna see nimekiri tehisarule kontekstiks, siis ei paku see uuemate versioonide käske.
- AutoCAD LT-l .NET API-t pole, nii et seda sel viisil ühendada ei saa. Täis-AutoCAD-il on.
- The fastest way to learn the API is to record a macro: draw by hand, then read the generated code.
- The interop DLL shows exactly what exists in your version (Visual Studio Object Browser). Give that list to the AI as context so it does not suggest calls from newer versions.
- AutoCAD LT has no .NET API, so it cannot be connected this way. Full AutoCAD can.
Fusion: MCP on juba sees
Fusion: MCP is built in
Autodesk Fusionis on kohalik MCP-server sisse ehitatud: Preferences → General → API ja linnuke „Fusion MCP Server“. Server töötab ainult siis, kui Fusion on lahti, ja kuulab ainult oma arvutis (127.0.0.1), nii et mudelid masinast välja ei lähe. Fusioni API on Pythonis ja C++-is, C#-i seal pole.
Autodesk Fusion has a local MCP server built in: Preferences → General → API and tick “Fusion MCP Server”. It runs only while Fusion is open and listens only on the local machine (127.0.0.1), so models never leave the PC. Fusion’s API is Python and C++, not C#.
Sellega lasin Claude’il ehitada parameetrilise lengi tapiühenduse ja seejärel terve tuletõkkeukse mudeli koos hingede ja lukuga. Fusion tegi mudelist ka automaatse 2D-joonise. See andis hea ülevaate, aga tootmiseks sellest ei piisanud: puudusid konkreetsed mõõdud ja lõiked ning detailide nimekiri oli üldine.
With it, Claude built a parametric frame mortise-and-tenon joint and then a full fire-door model with hinges and lock. Fusion also generated an automatic 2D drawing. It gave a good overview, but was not enough for production: specific dimensions and sections were missing and the parts list was generic.
Katsetasin Fusion Personal litsentsiga, mis on mõeldud ainult mitteäriliseks kasutuseks. Tootmises on vaja kommertslitsentsi.
I tested with a Fusion Personal licence, which is for non-commercial use only. Production use needs a commercial licence.
Milleks see sobib ja milleks mitte
What it is good for — and what not
| Ülesanne | Sobib? | Miks |
|---|---|---|
| Uue detaili või sõlme kiire prototüüp | Jah | kirjeldad sõnadega, mudel on minutitega olemas |
| Furnituuri 3D-teegi ehitamine | Jah | korduv töö tootja mõõtude järgi |
| Tapi- ja liiteloogika kontroll enne programmeerimist | Jah | geomeetria vead tulevad välja enne koodi |
| Üksiku eritellimuse modelleerimine | Jah | üks kord, aga palju detaile |
| Tellimuste joonised tootmisse automaatselt | Ei | vajab avatud töölauaprogrammi; serveris töötav oma kood on kindlam ja kiirem |
| Tootmiseks valmis tööjoonised | Veel mitte | automaatjoonistel puuduvad mõõdud, lõiked ja täpne detailide nimekiri |
| Task | Fit? | Why |
|---|---|---|
| Quick prototype of a new part or joint | Yes | describe it in words, the model exists in minutes |
| Building a 3D hardware library | Yes | repetitive work from manufacturer dimensions |
| Checking joinery logic before coding it | Yes | geometry mistakes show up before the code |
| Modelling a one-off custom order | Yes | done once, but with many parts |
| Automatic order drawings for production | No | needs an open desktop app; your own server-side code is more reliable and faster |
| Production-ready shop drawings | Not yet | automatic drawings lack dimensions, sections and an exact parts list |
CAD koos MCP-ga on hea assistent inimese kõrval, mitte tehas, mis toodab joonised ise. Masstootmise joonised genereerib endiselt oma kood serveris.
CAD with MCP is a good assistant next to a person, not a factory that produces drawings by itself. Production drawings at volume are still best generated by your own code on a server.
Õppetunnid
Lessons
- Alusta väikseimast testist: üks joon ja üks ring näitavad 15 minutiga, kas API on olemas ja töötab.
- Anna tehisarule täpne API kirjeldus oma versiooni kohta. Muidu pakub see käske, mida sinu versioonis pole.
- Kontrolli litsentsi: API ei pruugi kuuluda odavamatesse pakettidesse ja isiklik litsents ei luba ärilist kasutust.
- Tootmise mõõdud ja kokkulepped pead ise andma. Tehisaru valib tööriistad ja teeb korduva modelleerimise kiiresti, aga reeglid tulevad sinult.
- Hoia kõik kohalikus masinas: nii DraftSighti COM kui ka Fusioni MCP töötavad ainult samas arvutis.
- Start with the smallest test: one line and one circle show in 15 minutes whether the API exists and works.
- Give the AI an exact API description for your version. Otherwise it suggests calls your version does not have.
- Check the licence: the API may not be in the cheaper editions, and a personal licence does not allow commercial use.
- Production dimensions and conventions have to come from you. The AI picks the tools and does repetitive modelling fast, but the rules are yours.
- Keep everything local: both DraftSight’s COM and Fusion’s MCP work only on the same PC.