?
Solved

.net Autodesk.Aec.Modeler.Body

Posted on 2010-01-01
2
Medium Priority
?
601 Views
Last Modified: 2013-12-04
Hello,

I am new to .Net programming in AutoCAD Architecture and going thru the samples from Autodesk.
In a sample they create a cone thru VB.NET.

I managed to alter the code to draw a 3D box with the following code:
    Private Function CreateMassBox(ByVal InsPnt As Point3d, ByVal Afmeting3D As Vector3d) As ObjectId
        ' Functie om een 3D box te tekenen...
        Dim db As Database = HostApplicationServices.WorkingDatabase
        Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
        Dim id As ObjectId
        Dim t As Transaction = tm.StartTransaction()
        Try
            Dim bt As BlockTable = tm.GetObject(db.BlockTableId, OpenMode.ForRead, False)
            Dim btr As BlockTableRecord = tm.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
            Dim temp As Autodesk.Aec.DatabaseServices.MassElement = Autodesk.Aec.DatabaseServices.MassElement.Create(ShapeType.BoundaryRepresentation)
            Dim body As Autodesk.Aec.Modeler.Body = Autodesk.Aec.Modeler.Body.Box(InsPnt, Afmeting3D)
            temp.SetDatabaseDefaults()
            temp.SetBody(body, False)
            id = btr.AppendEntity(temp)
            tm.AddNewlyCreatedDBObject(temp, True)
            t.Commit()
        Finally
            t.Dispose()
        End Try
        Return id
    End Function

I also tried to create a 3D body of the "RightTriangle" type, but i can't figure out how to do this and i can't find any documentation or samples about this.
Can anyone help me with a sample?

Kind regards,

Marco
0
Comment
Question by:marco_greven
2 Comments
 
LVL 11

Expert Comment

by:darrenmcwi
ID: 26283129
You'll find a larger pool of Autodesk .Net programmers here that should be able to answer your question...

http://www.theswamp.org/
0
 

Accepted Solution

by:
marco_greven earned 0 total points
ID: 26285263
I found a sample of the code and will share it here:

<code_begin>
                                private ObjectId CreateMassTriangle()
                                {
                                                Database db = HostApplicationServices.WorkingDatabase;
                                                Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;
                                                ObjectId id = new ObjectId();
                                                Transaction t = tm.StartTransaction();
                                                try
                                                {
                BlockTable bt = tm.GetObject(db.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead, false) as BlockTable;
                BlockTableRecord btr = tm.GetObject(bt[BlockTableRecord.ModelSpace], Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, false) as BlockTableRecord ;
               
                 MassElement massElem12 = MassElement.Create(ShapeType.RightTriangle);
                massElem12.ColorIndex = 12;
                massElem12.Location = new Point3d(60.0, 30.0, 0.0);
                massElem12.Width = 40.0;
                massElem12.Depth = 20.0;
                massElem12.Height = 50.0;

                id = btr.AppendEntity(massElem12);
                tm.AddNewlyCreatedDBObject(massElem12, true);
                                t.Commit();
                                }
                                finally
                                {
                                                t.Dispose();
                                }
                                return id;
                }

<code_end>


Regards,

Marco
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
The following article will describe how to add/edit a dimension style through AutoCAD VBA. AutoCAD VBA has its quirks and when it comes to dimensions and controlling how they look through VBA.  This is where AutoCAD can be vividly confusing. The…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question