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

Unknown Commands

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

Unknown Commands

Trying to get up to speed with VB.Net and am using Visual Studio 2008 and the acdbmgd and acmgd wrappers from Autocad 2009. Have set up the class library per the instructions in 'Autocad 2007 .NET API Training Lab - VB' and have set up Acad 09 as the external program on the debug tab. ! am able to netload the application (after building it) however when I enter the command AutoCAD returns unknown command.

Am working through Lab3 and using the following: Public Function CreateEmployee().

Seem to recall something from somewhere most likely an AU class about different versions of autocad and compatibility with different versions of Visual Studio.

Any help is appreciated.
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

Make sure that you set Copy Local for acmgd.dll and acdbmgd.dll to False.
Message 3 of 12
Anonymous
in reply to: Anonymous

You have to use the correct version of the .NET Framework to compile
your code. (I think 2009 has to be 3.0)

On 1/13/2010 9:19 AM, jim.brinkmeyer@otak.com wrote:
> Trying to get up to speed with VB.Net and am using Visual Studio 2008 and the acdbmgd and acmgd wrappers from Autocad 2009. Have set up the class library per the instructions in 'Autocad 2007 .NET API Training Lab - VB' and have set up Acad 09 as the external program on the debug tab. ! am able to netload the application (after building it) however when I enter the command AutoCAD returns unknown command.
>
> Am working through Lab3 and using the following: Public Function CreateEmployee().
>
> Seem to recall something from somewhere most likely an AU class about different versions of autocad and compatibility with different versions of Visual Studio.
>
> Any help is appreciated.
Message 4 of 12
chiefbraincloud
in reply to: Anonymous

I think 2009 was still on version 2, but regardless, I am compiling to version 2, using VS2005, running in ACAD2010, which I know was written to 3 or 3.5. I have had no trouble yet.

When I changed references from 2009 ACAD to 2010, for some reason unknown to me the Studio required me to add a reference to the newer Windows PresentationCore version 3.00, but that is the only reference I have to version 3 files.

I believe the other comment about copy local is the most likely, but there are a few other potential causes for the commands not being recognized. (The class or module containing them must be public, and the subs themselves must be public, for instance)

As a matter of fact, I just noticed you said Public Function, but command methods have to be Subs with no arguments. I tried it on my machine and I get a binding error at runtime, as opposed to unknown command, so maybe you just typed Function in the post out of habit?

Also, if you are following along with the labs, then I don't think this is the problem, but if you got ahead of yourself and put in a class with the CommandClass attribute, Autocad will only find commands in that class. CommandMethods outside the CommandClass will be ignored.

Edited by: chiefbraincloud on Jan 13, 2010 2:07 PM

Ok, read more carefully... Now that I see you are using VS 2008, maybe cwitt had the right Idea, wrong version. (while I am able to compile to .NET 2, and run in 2010 built for 3, I don't think you could compile to 3 and run in something built for .NET 2, which could be happening)
Dave O.                                                                  Sig-Logos32.png
Message 5 of 12
Anonymous
in reply to: Anonymous

Thanks that did the trick now I'm running into the error: Error binding to target method. I'm sure that's something in my code though.

So what does 'Make sure that you set Copy Local for acmgd.dll and acdbmgd.dll to False.' mean ?

(and) where does one set the .net framework version?
Message 6 of 12
chiefbraincloud
in reply to: Anonymous

If copy local is true, then copies of those references will be placed in the build output directory of your program, and that messes things up.

I am still on VS 2005, and I don't think it has the setting, but a few months ago when I played around with VS 2008 Professional Trial version I believe I saw a setting for Target Framework. (I couldn't really tell you exactly where, but I think it was in the project properties pages)

With this latest comment, I don't think that is your problem, because the new error message is the same one I got when I tried a command method declared as a function. Methods declared with the CommandMethod Attribute must be subs. That should take care of the Binding error.
Dave O.                                                                  Sig-Logos32.png
Message 7 of 12
Anonymous
in reply to: Anonymous

Everyone --
Thanks got it figured out and running in VS08 to ACAD09 works fine. The tip on 'copy local' did the trick on my initial problem and the tip on using a sub and dot a function got rid of my binding problem. Interestingly the 'Acad 2007 Managed VB.NET Training 3 Labs' doc. shows the code as a function.

Regardless my thanks to you all. I was jogging along fine and then had to re-burn my laptop (a virus over the holidays and a scrambled registry) and I installed VS 2008 and the latest Framework and tried to just jump back in and go for it.

Think I'm back on track now, thanks again.
Message 8 of 12
Anonymous
in reply to: Anonymous

>> Public Function CreateEmployee().

Does the lab actually show this?

It can't be a Function, it must be a Sub.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message
news:6317594@discussion.autodesk.com...
Trying to get up to speed with VB.Net and am using Visual Studio 2008 and the
acdbmgd and acmgd wrappers from Autocad 2009. Have set up the class library per
the instructions in 'Autocad 2007 .NET API Training Lab - VB' and have set up
Acad 09 as the external program on the debug tab. ! am able to netload the
application (after building it) however when I enter the command AutoCAD returns
unknown command.

Am working through Lab3 and using the following:
Public Function CreateEmployee().

Seem to recall something from somewhere most likely an AU class about different
versions of autocad and compatibility with different versions of Visual Studio.

Any help is appreciated.
Message 9 of 12
Anonymous
in reply to: Anonymous

Yes... that is I believe so Here's to code right out of the doc file.
_
Public Function CreateEmployee()

Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim Circle As Circle = New Circle(New Point3d(10, 10, 0), Vector3d.ZAxis, 2.0)
Dim bt as BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btr as BlockTableRecord = trans.GetObject(bt(btr.ModelSpace), OpenMode.ForWrite)
btr.AppendEntity(circle)
trans.AddNewlyCreatedDBObject(circle, True)
trans.Commit()
Catch
MsgBox("Error Adding Entities")
Finally
trans.Dispose()
End Try
End Function

Now it may be that I'm missing something I'm just part way through the 3rd lab and there may be something further along that makes this work.
Anyway thanks again everyone.
Message 10 of 12
Anonymous
in reply to: Anonymous

Well, it's really unfortunate that Autodesk-provided training materials are that
bad.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message
news:6317883@discussion.autodesk.com...
Yes... that is I believe so Here's to code right out of the doc file.
_
Public Function CreateEmployee()

Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim Circle As Circle = New Circle(New Point3d(10, 10, 0),
Vector3d.ZAxis, 2.0)
Dim bt as BlockTable = trans.GetObject(db.BlockTableId,
OpenMode.ForRead)
Dim btr as BlockTableRecord = trans.GetObject(bt(btr.ModelSpace),
OpenMode.ForWrite)
btr.AppendEntity(circle)
trans.AddNewlyCreatedDBObject(circle, True)
trans.Commit()
Catch
MsgBox("Error Adding Entities")
Finally
trans.Dispose()
End Try
End Function

Now it may be that I'm missing something I'm just part way through the 3rd lab
and there may be something further along that makes this work.
Anyway thanks again everyone.
Message 11 of 12
Anonymous
in reply to: Anonymous

What might explain it is that back when those materials were written, the
managed runtime actually allowed Functions to be used for CommandMethods, and
would just ignore their result.

But that doesn't excuse not maintaning them to work correctly with the current
release.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message
news:6317883@discussion.autodesk.com...
Yes... that is I believe so Here's to code right out of the doc file.
_
Public Function CreateEmployee()

Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim Circle As Circle = New Circle(New Point3d(10, 10, 0),
Vector3d.ZAxis, 2.0)
Dim bt as BlockTable = trans.GetObject(db.BlockTableId,
OpenMode.ForRead)
Dim btr as BlockTableRecord = trans.GetObject(bt(btr.ModelSpace),
OpenMode.ForWrite)
btr.AppendEntity(circle)
trans.AddNewlyCreatedDBObject(circle, True)
trans.Commit()
Catch
MsgBox("Error Adding Entities")
Finally
trans.Dispose()
End Try
End Function

Now it may be that I'm missing something I'm just part way through the 3rd lab
and there may be something further along that makes this work.
Anyway thanks again everyone.
Message 12 of 12
Anonymous
in reply to: Anonymous

In the visual studio vbproj inside of the class.vb they used Sub - not
trying to find an excuse for them, just saying that what it is on the doc
does not match with the solution... nice.


"Tony Tanzillo" wrote in message
news:6317893@discussion.autodesk.com...
What might explain it is that back when those materials were written, the
managed runtime actually allowed Functions to be used for CommandMethods,
and
would just ignore their result.

But that doesn't excuse not maintaning them to work correctly with the
current
release.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message
news:6317883@discussion.autodesk.com...
Yes... that is I believe so Here's to code right out of the doc file.
_
Public Function CreateEmployee()

Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim Circle As Circle = New Circle(New Point3d(10, 10, 0),
Vector3d.ZAxis, 2.0)
Dim bt as BlockTable = trans.GetObject(db.BlockTableId,
OpenMode.ForRead)
Dim btr as BlockTableRecord = trans.GetObject(bt(btr.ModelSpace),
OpenMode.ForWrite)
btr.AppendEntity(circle)
trans.AddNewlyCreatedDBObject(circle, True)
trans.Commit()
Catch
MsgBox("Error Adding Entities")
Finally
trans.Dispose()
End Try
End Function

Now it may be that I'm missing something I'm just part way through the 3rd
lab
and there may be something further along that makes this work.
Anyway thanks again everyone.

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