.NET

Reply
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 1 of 6 (114 Views)

EllipseJig example in VB

114 Views, 5 Replies
02-20-2006 03:44 PM
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.
Distinguished Contributor
jbooth
Posts: 223
Registered: ‎02-17-2006
Message 2 of 6 (114 Views)

Re: EllipseJig example in VB

02-20-2006 04:34 PM 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. :smileywink:
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 3 of 6 (114 Views)

Re: EllipseJig example in VB

05-17-2006 08:13 PM 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
Distinguished Contributor
cgay
Posts: 125
Registered: ‎08-02-2005
Message 4 of 6 (114 Views)

Re: EllipseJig example in VB

05-18-2006 08:59 AM 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
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 5 of 6 (114 Views)

Re: EllipseJig example in VB

05-18-2006 06:26 PM 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.
Distinguished Contributor
cgay
Posts: 125
Registered: ‎08-02-2005
Message 6 of 6 (114 Views)

Re: EllipseJig example in VB

05-18-2006 08:51 PM 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.