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
Solved! Go to Solution.
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
"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.
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?)
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.
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.LabelStyleC
ollection = civDoc.Styles.LabelStyles.PointLabelStyles.LabelSt yles Try Dim id As ObjectId = styles(name) PointLabelStyleExists = True Catch ex As ArgumentException End Try End Function
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.