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

VB.NET - SET METHOD ON ELLIPSE

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ProfWolfMan
2556 Views, 2 Replies

VB.NET - SET METHOD ON ELLIPSE

Hi all,

 

I am trying to create a ellipse using set method.

 

But i got 'eGeneralModelingFailure' exception when executing set method.

 

I can not find any related post about this.

 

Herewith i attached my code.

 

Please give a try!

 

Thanks & Regards,

G

 

Thanks & Regards,
G
2 REPLIES 2
Message 2 of 3
Hallex
in reply to: ProfWolfMan

Try to rewrite the following Sub DrawEllipse on Function

This will draw an ellipse and ellipse arcs as well

    <CommandMethod("elp")> _
    Public Sub temp()
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
        Dim acEditor As Editor = acDoc.Editor
        Using trans As Transaction = db.TransactionManager.StartTransaction()
            Dim btr As BlockTableRecord = CType(trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
            DrawEllipse(btr, trans, New Point3d(0, 0, 0), 0.6, 20, 0.0, Math.PI * 2.0)
            trans.Commit()
        End Using
    End Sub
    Public Sub DrawEllipse(ByRef btr As BlockTableRecord, ByRef trans As Transaction, _
ByVal origPt As Point3d, ByVal radr As Double, _
ByVal leng As Double, ByVal sang As Double, ByVal eang As Double)
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim x As Vector3d = db.Ucsxdir
        Dim y As Vector3d = db.Ucsydir
        Dim normalVec As Vector3d = x.CrossProduct(y)
        Dim axisvec As Vector3d = normalVec.GetNormal()

        Dim elp As Ellipse = New Ellipse(origPt, _
        axisvec, _
        New Vector3d(0, leng / -2, 0.0), _
        radr, _
        sang, _
        eang)
        btr.AppendEntity(elp)
        trans.AddNewlyCreatedDBObject(elp, True)
    End Sub

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 3
ProfWolfMan
in reply to: ProfWolfMan

Hi,

 

Thank you very much for your help.

 

When i run your code with my own parameter values to draw ellipse, it returns exception of 'elockviolation'.

 

then, i add below lines

 

Using acLckDoc As DocumentLock = acDoc.LockDocument()

....'using transaction

....'end using

End using

It happens all of my code. I dont know where i am wrong?

I am always open blocktable record in openforwrite mode only. even though elockviolation error occurs .

Any idea?

Thanks & regards,

G

Thanks & Regards,
G

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