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!
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.
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)