VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

work on autocad from MATLAB

6 REPLIES 6
Reply
Message 1 of 7
tuli
3682 Views, 6 Replies

work on autocad from MATLAB

Hello,

Is it possible to run autocad and perform VBA-like commands from Matlab.
If yes please give me some references or any info for a 'jump start'

Thanks you

Tuli
6 REPLIES 6
Message 2 of 7
bcoward
in reply to: tuli

Tuli,

www.mathworks.com

Go there and do a search for AutoCAD, I believe you might find what your looking for.

G'Luck

Bob
Message 3 of 7
Anonymous
in reply to: tuli

feature('COM_SafeArraySingleDim', 1);feature('COM_PassSafeArrayByRef', 1);
AcadApp=actxserver('AutoCAD.Application.19.1'); % AutoCAD2014
AcadApp.Visible = true();
AcadDoc = AcadApp.ActiveDocument;
AcadModelSpace = AcadDoc.ModelSpace;

 

lineObj = AcadModelSpace.AddLine([0,0,0]',[1,0,0]'); % drawing a line

 

% i am just starting it, all the codes above are available. But there are problems when i tried to AddRegion.

% if you know how to AddRegion, i'll be very grateful!Heart

Message 4 of 7
caplazy
in reply to: tuli
Message 5 of 7
1554503032
in reply to: Anonymous

Very thanks for your share! The 'feature' is unbelievable.

This question has been bothering me for many days, now it has been solved, I feel very happy.

And, I really hope we can have more communication, looking forward to your replay.

Message 6 of 7
rabail.khan
in reply to: Anonymous

Hi, when i use the handles for outer and inner boundary of hatch in autocad i get the following error:

Error using Interface.240A7B13_918B_4CDC_B1E5_A5ED42867FD0/AppendInnerLoop
Invoke Error, Dispatch Exception:
Source: AutoCAD.Application
Description: Invalid object array
Help File: C:\Program Files\Autodesk\AutoCAD 2020\HELP\OLE_ERR.CHM
Help Context ID: 8021007b

 

 

Here is my code:

acad = actxGetRunningServer('AutoCAD.Application');
documents = acad.Documents;
e_doc=documents.Open('D:\matlab\UKPNgrp.dxf');

feature('COM_SafeArraySingleDim', 1)
feature('COM_PassSafeArrayByRef', 1)
acad.Visible = true();
AcadModelSpace = e_doc.ModelSpace
archandle = AcadModelSpace.AddArc([5;3;0], 3, 0, 3.142)

hatchHandle = AcadModelSpace.AddHatch(0, "ANSI31", 0)
lineHandle = AcadModelSpace.AddLine (archandle.startPoint', archandle.endPoint') %take transpose so coordinates are column matrix
circleHandle = AcadModelSpace.AddCircle([5; 4.5; 0], 1)

hatchHandle.AppendOuterLoop ([archandle; lineHandle])
hatchHandle.AppendInnerLoop (circleHandle)

Message 7 of 7
orellandres
in reply to: rabail.khan

Encontraste solucion?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost