.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

okok Now what?

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
762 Views, 11 Replies

okok Now what?

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
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

Imports Autodesk.AutoCAD.InterOp
Imports Autodesk.AutoCAD.InterOp.Common

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Message 3 of 12
Anonymous
in reply to: Anonymous

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
Message 4 of 12
Anonymous
in reply to: Anonymous

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
Message 5 of 12
Anonymous
in reply to: Anonymous

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
Message 6 of 12
Anonymous
in reply to: Anonymous

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...
Message 7 of 12
Anonymous
in reply to: Anonymous

>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...
Message 8 of 12
Anonymous
in reply to: Anonymous

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...
Message 9 of 12
Anonymous
in reply to: Anonymous

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...
Message 10 of 12
GuntherS
in reply to: Anonymous

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
Message 11 of 12
jbryant4
in reply to: Anonymous

Dang....All that code just to create a circle??

Sorry....couldn't resist.
Message 12 of 12
Paul Richardson
in reply to: Anonymous

Sorry I didn't see your post, I use a news-reader
not the browser usually.

'Helper' is just the name oft the class that holds
the method to connect to autocad 'GetAcad'.
Could be anything, it was the name used in the
Lab I was following by Roy Pereira.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost