AutoCAD Civil 3D Customization

Reply
Valued Contributor
Posts: 72
Registered: ‎02-18-2010
Message 1 of 16 (709 Views)
Accepted Solution

vb.net 2012 (cogo) point styles

709 Views, 15 Replies
10-11-2012 04:38 PM

all I want to do is get the point style from a user selected COGO point (& then later set it to a different one). This point might be selected along with lines, blocks, and/or whatever. I can get to where I'm dealing with the POINTENTITYobject but one can't access the style from that (or can we?). From what I gather I need to set am AECCPOINT variable from the pointentity object, using the pointentity number property as an index for the aeccpointS index method. THing is, I can't get the AECCPOINTS collection. with is a part of the civil database.

after much research I have the following relevent code:

    Dim PtNumber As Double
    Dim ePoint As PointEntity
    Dim aPoint As AeccPoint
    Dim aPoints As AeccPoints
    Dim aPointsIds As ObjectIdCollection

 

 

    Private m_oAeccDb As IAeccDatabase


    <CommandMethod("CDE")> _
    Public Sub ChangeToDemoCivil()        'this is the civil3d version, which works on COGO point styles too










        ACF.SsGetStuff("Select objects to be placed onto DEMO layers:")

        Dim idArray As ObjectId() = ACF.ssResult.GetObjectIds()

        For Each id As ObjectId In idArray

            Using acTrans As Transaction = ACF.Db.TransactionManager.StartTransaction()


                Try

                    ePoint = CType(acTrans.GetObject(id, OpenMode.ForWrite), PointEntity)


                    If Not ePoint Is Nothing Then        'it is a cogo point, so change to appropriate demo style

                        PtNumber = ePoint.PointNumber


                        aPoints = m_oAeccDb.Points

 ACF.getstuff () is an external funtion that stores a list of objectids of selected objects in  ACF.ssResult (as Autodesk.AutoCAD.EditorInput.SelectionSet)

 

I am getting a fatal error on this:

 

aPoints = m_oAeccDb.Points

 

 

*Expert Elite*
Jeff_M
Posts: 3,962
Registered: ‎07-22-2003
Message 2 of 16 (697 Views)

Re: vb.net 2012 (cogo) point styles

10-11-2012 07:56 PM in reply to: kcimos

You don't need to go about it in that fashion. See if this helps:

 

            Dim ss() As ObjectId = ssResult.Value.GetObjectIds()
            Dim ptEnt As PointEntity
            Using tr As Transaction = doc.Database.TransactionManager.StartTransaction()
                For Each objId As ObjectId In ss
                    ptEnt = objId.GetObject(OpenMode.ForRead, False)
                    Dim ptObj As AeccLandLib.AeccPoint = ptEnt.AcadObject
                    Dim ptStyle As AeccLandLib.AeccPointStyle = ptObj.Style
                    doc.Editor.WriteMessage("Name of the selected point's syle is: " + ptStyle.Name)
                Next
            End Using

 

Jeff_M, also a frequent Swamper
Valued Contributor
Posts: 72
Registered: ‎02-18-2010
Message 3 of 16 (687 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 05:40 AM in reply to: kcimos

"Dim ptObj As AeccLandLib.AeccPoint = ptEnt.AcadObject"

 

that was the key bit of info I needed.

 

I never would have thouht that a PointEntity had AcadObject property which had a Style property. Now I can look into this aspect of the civil 3d object model, and probably gain enlightenment to other bizarre things.

 

thanks

Valued Contributor
Posts: 72
Registered: ‎02-18-2010
Message 4 of 16 (677 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 11:27 AM in reply to: kcimos

OK, now how can I access the point's label style?

Valued Contributor
Posts: 72
Registered: ‎02-18-2010
Message 5 of 16 (676 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 11:28 AM in reply to: kcimos

OK, I figured that out, I had to go bask to the PointEntity object

Valued Contributor
Posts: 72
Registered: ‎02-18-2010
Message 6 of 16 (673 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 11:45 AM in reply to: kcimos

opps sorry, its under PointEntity.AcadObject

Valued Contributor
Posts: 72
Registered: ‎02-18-2010
Message 7 of 16 (666 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 02:40 PM in reply to: kcimos

OK, now I'm trying work out how to test if a point style exists.

All I can find is a similar method that was causing my initial post, for getting the pointstyles from the document this time, which crashes.

 

I'm looking at the civil3d 2012 developers guide's section on COM

& so to try to retrofit my code to fit with their examples, I add this:

Dim oAcadApp As AcadApplication
Set oAcadApp = ThisDrawing.Application
' Specify the COM name of the object we want to access.
' Note that this always accesses the most recent version
' of AutoCAD Civil 3D installed.
Const sCivilAppName = "AeccXUiLand.AeccApplication.6.0"
Dim oCivilApp As AeccApplication
Set oCivilApp = oAcadApp.GetInterfaceObject(sCivilAppName)
 
' Now we can use the AeccApplication object.
' Get the AeccDocument representing the currently
' active drawing.
Dim oDocument As AeccDocument
Set oDocument = oCivilApp.ActiveDocument
' Set the viewport of the current drawing so that all
' drawing elements are visible.
oCivilApp.ZoomExtents

 & the first error is that acadapplication is ambigous in the autodesk.autocad.interop

then I see that they are using "THISDRAWING" & "SET". so this documentation for COM is based on VBA, which makes sense, except VB.NET is what the guide is about.

 

so, anyone know of any way to test if a (point) style exists?

 

(anyway of copying or saving as one too?)

 

*Expert Elite*
Jeff_M
Posts: 3,962
Registered: ‎07-22-2003
Message 8 of 16 (662 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 03:17 PM in reply to: kcimos

I prefer to stay with the .NET API when possible. This will check if a PointStyle exists. Use the same idea for other styles.

 

    Function PointStyleExists(ByVal civDoc As CivilDocument, ByVal name As String) As Boolean
        Dim exists As Boolean = False
        Dim styles As PointStyleCollection = civDoc.Styles.PointStyles
        Try
            Dim id As ObjectId = styles(name)
            exists = True
        Catch ex As ArgumentException
        End Try
        PointStyleExists = exists
    End Function

 Or, depending on what you need it for, have it return the ObjectId if you need that.

Jeff_M, also a frequent Swamper
*Expert Elite*
Jeff_M
Posts: 3,962
Registered: ‎07-22-2003
Message 9 of 16 (658 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 04:07 PM in reply to: kcimos

kcimos wrote:

 

(anyway of copying or saving as one too?)

 


Not sure I understand this question.

Jeff_M, also a frequent Swamper
*Expert Elite*
Jeff_M
Posts: 3,962
Registered: ‎07-22-2003
Message 10 of 16 (654 Views)

Re: vb.net 2012 (cogo) point styles

10-12-2012 04:21 PM in reply to: Jeff_M

Here's how to test for the existence of a PointLabelStyle:

    Function PointLabelStyleExists(ByVal civDoc As CivilDocument, ByVal name As String) As Boolean
        PointLabelStyleExists = False
        Dim styles As Autodesk.Civil.DatabaseServices.Styles.LabelStyleCollection = civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles
        Try
            Dim id As ObjectId = styles(name)
            PointLabelStyleExists = True
        Catch ex As ArgumentException
        End Try
    End Function

 

Jeff_M, also a frequent Swamper

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Civil 3D

Twitter

Facebook

Blogs