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

How to Add AEC Space?

2 REPLIES 2
Reply
Message 1 of 3
ChrisPicklesimer
858 Views, 2 Replies

How to Add AEC Space?

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

 

2 REPLIES 2
Message 2 of 3
HolgerR
in reply to: ChrisPicklesimer

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
Message 3 of 3
ChrisPicklesimer
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)

 

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