How to Add AEC Space?

How to Add AEC Space?

ChrisPicklesimer
Advocate Advocate
1,324 Views
2 Replies
Message 1 of 3

How to Add AEC Space?

ChrisPicklesimer
Advocate
Advocate

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

 

0 Likes
1,325 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
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
0 Likes
Message 3 of 3

ChrisPicklesimer
Advocate
Advocate

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)

 

0 Likes