.NET

Reply
*john m
Message 1 of 12 (118 Views)

okok Now what?

118 Views, 11 Replies
05-21-2005 06:06 AM
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
*Mike Tuersley
Message 2 of 12 (118 Views)

Re: okok Now what?

05-21-2005 07:26 AM in reply to: *john m
Imports Autodesk.AutoCAD.InterOp
Imports Autodesk.AutoCAD.InterOp.Common

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Paul Richardson
Message 3 of 12 (118 Views)

Re: okok Now what?

05-21-2005 07:51 AM in reply to: *john m
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
*Paul Richardson
Message 4 of 12 (118 Views)

Re: okok Now what?

05-21-2005 07:51 AM in reply to: *john m
Sample Class to draw a circle,
and call from VBa. Sorry if this
posted twice. Email issues.


'
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
*Paul Richardson
Message 5 of 12 (118 Views)

Re: okok Now what?

05-21-2005 08:22 AM in reply to: *john m
btw. Not that I need to ask:-) but
could someone please tell me if
there is anything I am doing wrong.

I know the namespaces would make
more sense if I had flipped them making
"MyCircleClass" the main namespace.
and having "AddCircle" as a nested space.?

tks
Paul

"Paul Richardson" wrote in message
news:4852753@discussion.autodesk.com...
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
*john m
Message 6 of 12 (118 Views)

Re: okok Now what?

05-21-2005 08:46 AM in reply to: *john m
thanks for the hint mike
i am an idiot and still lost

here is my code
Dim thisapp As Autodesk.AutoCAD.Interop.AcadApplicationClass

Dim thisDrawing As Autodesk.AutoCAD.Interop.AcadDocumentClass

thisDrawing = thisapp.ActiveDocument




it compiles fine and then when i do netload it says the third line is no
good

thank you for looking at it
jm

"Mike Tuersley" wrote in message
news:4852731@discussion.autodesk.com...
Imports Autodesk.AutoCAD.InterOp
Imports Autodesk.AutoCAD.InterOp.Common

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Paul Richardson
Message 7 of 12 (118 Views)

Re: okok Now what?

05-21-2005 10:18 AM in reply to: *john m
>it compiles fine and then when i do netload it says the third line is no
>good

What are you compiling it to? Are you creating a NET object
or a COM object? Why the NETLOAD?


"john m" wrote in message
news:4852749@discussion.autodesk.com...
thanks for the hint mike
i am an idiot and still lost

here is my code
Dim thisapp As Autodesk.AutoCAD.Interop.AcadApplicationClass

Dim thisDrawing As Autodesk.AutoCAD.Interop.AcadDocumentClass

thisDrawing = thisapp.ActiveDocument




it compiles fine and then when i do netload it says the third line is no
good

thank you for looking at it
jm

"Mike Tuersley" wrote in message
news:4852731@discussion.autodesk.com...
Imports Autodesk.AutoCAD.InterOp
Imports Autodesk.AutoCAD.InterOp.Common

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*john m
Message 8 of 12 (118 Views)

Re: okok Now what?

05-21-2005 10:38 AM in reply to: *john m
i found an example of using the COM API
so i am making better progress now

the idea was that i wanted to use dotNet xml features and also resizable
forms
but still use the autocad COM

thanks all

"Paul Richardson" wrote in message
news:4852795@discussion.autodesk.com...
>it compiles fine and then when i do netload it says the third line is no
>good

What are you compiling it to? Are you creating a NET object
or a COM object? Why the NETLOAD?


"john m" wrote in message
news:4852749@discussion.autodesk.com...
thanks for the hint mike
i am an idiot and still lost

here is my code
Dim thisapp As Autodesk.AutoCAD.Interop.AcadApplicationClass

Dim thisDrawing As Autodesk.AutoCAD.Interop.AcadDocumentClass

thisDrawing = thisapp.ActiveDocument




it compiles fine and then when i do netload it says the third line is no
good

thank you for looking at it
jm

"Mike Tuersley" wrote in message
news:4852731@discussion.autodesk.com...
Imports Autodesk.AutoCAD.InterOp
Imports Autodesk.AutoCAD.InterOp.Common

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
*Paul Richardson
Message 9 of 12 (118 Views)

Re: okok Now what?

05-21-2005 10:40 AM in reply to: *john m
cool. Sorry for the C#. Though u were using
sharp not vb.

"john m" wrote in message
news:4852774@discussion.autodesk.com...
i found an example of using the COM API
so i am making better progress now

the idea was that i wanted to use dotNet xml features and also resizable
forms
but still use the autocad COM

thanks all

"Paul Richardson" wrote in message
news:4852795@discussion.autodesk.com...
>it compiles fine and then when i do netload it says the third line is no
>good

What are you compiling it to? Are you creating a NET object
or a COM object? Why the NETLOAD?


"john m" wrote in message
news:4852749@discussion.autodesk.com...
thanks for the hint mike
i am an idiot and still lost

here is my code
Dim thisapp As Autodesk.AutoCAD.Interop.AcadApplicationClass

Dim thisDrawing As Autodesk.AutoCAD.Interop.AcadDocumentClass

thisDrawing = thisapp.ActiveDocument




it compiles fine and then when i do netload it says the third line is no
good

thank you for looking at it
jm

"Mike Tuersley" wrote in message
news:4852731@discussion.autodesk.com...
Imports Autodesk.AutoCAD.InterOp
Imports Autodesk.AutoCAD.InterOp.Common

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
New Member
GuntherS
Posts: 1
Registered: ‎09-08-2005
Message 10 of 12 (118 Views)

Re: okok Now what?

09-08-2005 07:59 AM in reply to: *john m
I'm also working on a AutoCAD automation project.
And the code that I found here is very usefully, only : where does the function Helper.GetAcad(); come from?

BR,
Gunther S
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.