.NET

Reply
Valued Contributor
Chris.Picklesimer
Posts: 89
Registered: ‎04-07-2000
Message 1 of 3 (324 Views)

How to Add AEC Space?

324 Views, 2 Replies
07-17-2013 08:47 AM

ACA 2012

 

I am trying to figure out how to insert a 2D AEC Space with .net.  Using the code below, it appears as though a space is created but it shows up as only the "triangular error symbol".  I can select the symbol and it displays in the properties palette as a space,  Can anyone point me in the right direction as to the proper way to add an AEC Space?

 

Thanks.

 

Chris

 Using acTrans As Transaction = db.TransactionManager.StartTransaction()

            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead)

            Dim acBlkTblRec As BlockTableRecord
            acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            Dim myPPO As New PromptPointOptions("Pick first point: ")
            myPPO.AllowNone = True
            myPPO.UseBasePoint = False

            Dim myPPR As PromptPointResult = ed.GetPoint(myPPO)
            Dim i As Integer = 0

            Dim acPoly As Polyline = New Polyline()
            acPoly.SetDatabaseDefaults()

            While myPPR.Status = Autodesk.AutoCAD.EditorInput.PromptStatus.OK
                myPPO.UseBasePoint = True
                myPPO.BasePoint = myPPR.Value
                myPPO.Message = "Pick next point: "
                myPPR = ed.GetPoint(myPPO)
                i = i + 1
            End While

            If i > 3 Then

                acPoly.Closed = True

                acBlkTblRec.AppendEntity(acPoly)
                acTrans.AddNewlyCreatedDBObject(acPoly, True)

                Dim myProfile As New Autodesk.Aec.Geometry.Profile
                Autodesk.Aec.Geometry.Profile.CreateFromEntity(acPoly, Matrix3d.Identity)

                Dim mySpace As Space = New Space
                mySpace.SetDatabaseDefaults(db)
                mySpace.SetToStandard(db)
                mySpace.Associative = False
                mySpace.GeometryType = SpaceGeometryType.TwoD
                mySpace.Location = New Point3d(0, 0, 0)
                mySpace.SetBaseProfile(myProfile, Matrix3d.Identity)

                acBlkTblRec.AppendEntity(mySpace)
                acTrans.AddNewlyCreatedDBObject(mySpace, True)

            End If

            acTrans.Commit()
        End Using

 

Member
HolgerR
Posts: 3
Registered: ‎02-10-2010
Message 2 of 3 (315 Views)

Re: How to Add AEC Space?

07-17-2013 10:31 AM in reply to: Chris.Picklesimer
Hi Chris,
I'm not sure, maybe it's a copy&paste error but I use the CreateFromEntity function so:
myProfile = Autodesk.AEC.Geometry.Profile.CreateFromEntity(mySpaceProfile, myEdsp.CurrentUserCoordinateSystem)

 myEDsp is the current Application.DocumentManager.MdiActiveDocument.Editor

hope this helps

Holger
Valued Contributor
Chris.Picklesimer
Posts: 89
Registered: ‎04-07-2000
Message 3 of 3 (310 Views)

Re: How to Add AEC Space?

07-17-2013 11:02 AM in reply to: HolgerR

Hi Holger,

 

Thanks for the quick response!  That was it.  You saved me lots of time.

 

Chris

 

btw, in my original post I left this code out by mistake.  It is inside my while loop.

 

acPoly.AddVertexAt(i, New Point2d(myPPR.Value.X, myPPR.Value.Y), 0, 0, 0)

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.