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

EllipseJig example in VB

5 REPLIES 5
Reply
Message 1 of 6
flongsworth
308 Views, 5 Replies

EllipseJig example in VB

I am trying to translate the Ellipsejig sample from C# to VB so that I can modify it (and understand it). Can some C# guru explain what these statements mean in VB?

class EllipseJig : EntityJig

I know that class EllipseJig is the embedded class but what is the : EntityJig in terms of VB?

Also, what is the equivalent of

public EllipseJig(Point3d center,Vector3d vec):base(new Ellipse()) in VB, anybody? (ie what is :base(new Ellipse())

Attached is what I have so far. Any help is appriciated.
5 REPLIES 5
Message 2 of 6
jbooth
in reply to: flongsworth

class EllipseJig : EntityJig

just says that EllipseJig inherits from Entityjig. Try this:

public class EllipseJig
Inherits EntityJig

The next one...
public EllipseJig(Point3d center,Vector3d vec):base(new Ellipse())

translates to:

public sub new(byval point3d center, byval vector3d vec)
mybase.new(new Ellipse())
end sub


Someone correct me if I'm wrong, I typed this in a hurry. 😉
Message 3 of 6
flongsworth
in reply to: flongsworth

Thanks Jason (sorry for the delay)

Well I hadn't done much on this but finally got around to translating it to VB. I can get the example to run, but the ellipse does not update dynamically. It will create the ellipse at the end but I must be doing some thing wrong. Any body have a clue??
Here is the code
Message 4 of 6
cgay
in reply to: flongsworth

I have built a project which is attached. It is for VS 2005.
Let us know if it is what you are looking for or not.
C
Message 5 of 6
flongsworth
in reply to: flongsworth

Thanks a bunch CougerAC. Yes, you definitely shed some light on what I was doing wrong. I got my example to run fine.
This is what made the difference:

With DirectCast(Entity, Ellipse)
.Set(mCenterPt, _
New Vector3d(0, 0, 1), _
mMajorAxis, _
radiusRatio, _
0.0, 6.2831853071795862)
End With
In the update function and this property:
Friend Shadows ReadOnly Property Entity() As Entity
Get
Return MyBase.Entity
End Get
End Property

I did have a question. I am using the typical "Imports ...." at the beginning of my class, but I don't see that in your project. How does that work? We are using the same references and everything.

Now I have to try to adapt this sample to be able to insert blocks so that it mimics the native AutoCAD "insert" command. Is that possible?

Thanks again.
Message 6 of 6
cgay
in reply to: flongsworth

If you look in the "Project Properties" -> "References" tab, you'll see an "Imported Namespaces" section. This is for Global Imports, available to the entire project. But I don't want all those namespaces clogging up my intellisense, so I use global imports like "Imports AcadDS = Autodesk.Autocad.DatabaseServices" and "Imports AcadApp = Autodesk.Autocad.ApplicationServices.Application". This way I can create code like this:
Dim ellipseObj as AcadDS.Ellipse = New AcadDS.Ellipse
Or:
Dim Doc as AcadAS.Document = AcadApp.Documentmanager.MDIActiveDocument
etc....

There were a couple of areas in your example code translated from C# that would have created problems.
Like this:
jigOpts.UserInputControls = (UserInputControls.Accept3dCoordinates Xor UserInputControls.NoZeroResponseAccepted Xor UserInputControls.NoNegativeResponseAccepted)

I changed it to this:
jigOpts.UserInputControls = UserInputControls.Accept3dCoordinates Or UserInputControls.NoZeroResponseAccepted Or UserInputControls.NoNegativeResponseAccepted

Notice the OR instead of XOR. This could have also caused problems.

Notice also in the CommandMethod my use of the Using Construct. I am really glad that MS decided to add this to the language. I basically calls the "Dispose" method for you when the "End Using" code is encountered. BUT you must take care to trap errors INSIDE the using construct so it behaves correctly, especially if you are using it for a transaction.

Finally, I am not sure about inserting blocks with this method. I have never really tried. Maybe someone else has a suggestion for this.

C

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