Here is a c# class to create a circle,
and the call to the dll from VBA.
gl
Paul
'
Sub test()
Dim circle1 As New AddCircle.Circle
Dim xCoord As Double: xCoord = 10
Dim yCoord As Double: yCoord = 10
Dim zCoord As Double: zCoord = 0
Dim rad As Double: rad = 25
circle1.xCoord = xCoord
circle1.yCoord = yCoord
circle1.zCoord = zCoord
circle1.Radius = rad
circle1.Draw
End Sub
'
//
using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Runtime;
namespace AddCircle
{
namespace MyCircleClass
{
///
/// Summary description for Circle.
///
public interface IMyInterface1
{
double xCoord { set; get; }
double yCoord { set; get; }
double zCoord { set; get; }
double radius { set; get; }
void Draw();
}
// Class that implements the Interface
[ ClassInterface( ClassInterfaceType.None ) ]
public class Circle : IMyInterface1
{
private double _xCoord;
private double _yCoord;
private double _zCoord;
private double _radius;
public double zCoord
{
get
{
return _zCoord;
}
set
{
_zCoord = value;
}
} // interface properties implemented by zCoord
double IMyInterface1.zCoord
{
get { return zCoord; }
set { zCoord = value; }
}
public double xCoord
{
get
{
return _xCoord;
}
set
{
_xCoord = value;
}
} // interface properties implemented by xCoord
double IMyInterface1.xCoord
{
get { return xCoord; }
set { xCoord = value; }
}
public double yCoord
{
get
{
return _yCoord;
}
set
{
_yCoord = value;
}
} // interface properties implemented by yCoord
double IMyInterface1.yCoord
{
get { return yCoord; }
set { yCoord = value; }
}
public double radius
{
get
{
return _radius;
}
set
{
_radius = value;
}
} // interface properties implemented by xCoord
double IMyInterface1.radius
{
get { return radius; }
set { radius = value; }
}
public void Draw()
{
double[] centerPoint = new double[3];
AcadApplication myApp = Helper.GetAcad();
myApp.Visible = true;
AcadDocument myDoc = myApp.ActiveDocument;
centerPoint[0] = _xCoord;
centerPoint[1] = _yCoord;
centerPoint[2] = _zCoord;
myDoc.ModelSpace.AddCircle(centerPoint,_radius);
}
}
}
}
//
"john m" wrote in message
news:4852713@discussion.autodesk.com...
Hello,
I want to call COM objects from VB.NET
i set a reference under the COM tab for AutoCAD 2006 Type Library and
the AutoCAD/ObjectDBX Common 16.0 Type Library.
i used "Imports Autodesk.AutoCAD.Interop "
now how to get a pointer to, for example, the active document?
thanks for any help
jm