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

Late binding and enums

1 REPLY 1
Reply
Message 1 of 2
Anonymous
367 Views, 1 Reply

Late binding and enums

Hi,

I have a program in VB.Net with option strict off.
I don't want to make a reference to any Autodesk dll in my project. I do this to remain independent on the version of AutoCAD.

I create an AutoCad Instance like this.
Dim m_AcadApp as Object = CreateObject("Autocad.Application")

everything is fine until I need a constant. The constants are in ObjectDBX.

I know if I were linked to the dll in my project I could use the constants like this:
AutoCAD.AcAlignment.acAlignmentBottomCenter

Can I use the enums without knowing their value. Or do I need to rewrite each of them with their value in my code.
1 REPLY 1
Message 2 of 2
cgay
in reply to: Anonymous

okidoo,

You probably should look up the definition of Enum if you want a deeper explanation on this.

An Enumeration is a set of VALUES logically related to each other. Since you are late-binding, the compiler doesn't know what value to assign to acAlignmentBottomCenter (13 in this case). The acAlignmentBottomCenter variable is really a shared constant with the value of 13. The AcAlignment Enum is just a nice way of saying...I have this group of unique values which I want to assign names so that others will know what the values are for.

So, not only do you need to declare the constant acAlignmentBottomCenter, but you also need to assign its value of 13, because this is ultimately what AutoCAD 'sees' and it knows that 13 = acAlignmentBottomCenter.

This means that if you know the value of the Enum Member you want, you don't really to define it at all, you could just use 13. But acAlignmentBottomCenter doesn't equal anything if it is not defined.

Also note that Enums can be any of the following: Byte, Integer, Long, SByte, Short, UInteger, ULong, or UShort.

Here is the Enum you need.....

[code]
Enum AcAlignment As Integer
acAlignmentLeft = 0
acAlignmentCenter = 1
acAlignmentRight = 2
acAlignmentAligned = 3
acAlignmentMiddle = 4
acAlignmentFit = 5
acAlignmentTopLeft = 6
acAlignmentTopCenter = 7
acAlignmentTopRight = 8
acAlignmentMiddleLeft = 9
acAlignmentMiddleCenter = 10
acAlignmentMiddleRight = 11
acAlignmentBottomLeft = 12
acAlignmentBottomCenter = 13
acAlignmentBottomRight = 14
End Enum
[/code]

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