Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.Net and Autocad programming?

Status
Not open for further replies.

CadDesigner

Programmer
Nov 25, 2003
18
FR
Hi,
Until this moment I occasionally program with VB6 for Autocad.(not VBA)
VB6 is running void and I wonder if VB.Net will work as fine as VB6 did.
For instance,I heard that VB.Net cannot handle variants.
Autocad does,Is this a problem?
Anybody who has some experience on this?

Regards,
Paul

 
I have just recently purchased a copy of VB.net. As I worked through the process of migrating some code from VB6 to VB.net which is required if you are going to upgrade your code to .net. I have decided to hold off on .net until i had more time to work with it it is a whole new animal compared to VB6. If you have a sec would you know why the code list below would exit the sub on the Set objTapSS? I amd trying to add another selectionset and it works fine when I run it with just Set objSS. I have been working with VB6 and CAD2000i off and on for about a year know. So I am still getting the hang of it.

Thanks man

Sub DetermineConnects()
Dim lngMode As Long
Dim objSS As AcadSelectionSet
Dim objTapSS As AcadSelectionSet
Dim strTempHndl As String
Set objSS = AcadApp.Documents(1).SelectionSets.Add("objSS")
Set objTapSS = AcadApp.Documents(1).SelectionSets.Add("objTapSS")
lngMode = acSelectionSetCrossing
dblsLL(0) = dblStartX - dblProj
dblsLL(1) = dblStartY - dblProj
dblsLL(2) = 0
dblsUR(0) = dblStartX + dblProj
dblsUR(1) = dblStartY + dblProj
dblsUR(2) = 0
dbleLL(0) = dblEndX - dblProj
dbleLL(1) = dblEndY - dblProj
dbleLL(2) = 0
dbleUR(0) = dblEndX + dblProj
dbleUR(1) = dblEndY + dblProj
dbleUR(2) = 0
 
Hi Guys,

VB.NET is getting more and more popular with AutoCAD among developers. And yes, there are caveats you have to look for. One is variant - .NET uses Object. Another is when using an array of integers - in VB6 an integer is 16 bits, in .NET an integer is 32 bits, so we need to use Int16 (shorts). There are more but I would invest the time to start working with it.

irfcbabe,
Sounds like the selection set already exists. Put in some error handling to see what the description is. You should check to see if the selection already exists, and if it does, delete it before adding it.

somethng like this.
on error resume next
Set objSS = AcadApp.Documents(1).SelectionSets.Add("objSS")
if err then
AcadApp.Documents(1).SelectionSets.Item("objSS").delete
Set objSS = AcadApp.Documents(1).SelectionSets.Add("objSS")
err.clear
end if

Good Luck,

Scott

 
Hi Irfcbabe,
Scott already told you where I was thinking about as well.
Another solution could be to set your selectionsets in an init-routine first.This init routine should be used only once.
Fill in a subroutine your selection sets, do whatever you like with it and .clear the selectionset before leaving the subroutine.
This keeps your selection set "alive" , clean and you don't have to error-check it.

Have fun!
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top