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.
Solved by Jeff_M. Go to Solution.
Solved by Jeff_M. Go to Solution.
Solved by Jeff_M. 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.
thanks
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.LabelStyleCollection = civDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles Try Dim id As ObjectId = styles(name) PointLabelStyleExists = True Catch ex As ArgumentException End Try End Function
anyway of copying a pointstyle. Or would I have to iterate through all the various point style pieces & recreate them in a new style? & If the only way is to iterate and copy each item into a new style using VB variables, is there a way of finding what block, if any, the marker is using?
To copy a pointstyle (assuming you have the existing style ObjectId as id):
Using tr As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction() Dim style As PointStyle = TryCast(id.GetObject(OpenMode.ForRead, False, True), PointStyle) Dim newId As ObjectId = style.CopyAsSibling(style.Name + " - (Copy)") tr.Commit() End Using
As for the point style marker, use the MarkerType and MarkerSymbolName properties of the style object.
See here for more info: http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/net/html/2953dd7d-c44a-9c3a-7fa0-74a3fef...
this:
Dim newId As ObjectId = style.CopyAsSibling(style.Name + " - (Copy)")
is causing a fatal error
I was already in a transaction, & I figured this didn't need to be in its own (sub)transaction, so while troubleshooting, since the syntax in your code is a little different from what I'm used to , I figured I'd go ahead & nest it into another transaction, when I pasted this code:
Using tr As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
I get the following error:
Error 1 'Transactio' is not a member of 'Autodesk.AutoCAD.DatabaseServices.Database'
is hostapplicationservices any different than the autocad database (which is what my transactions are started from)? I mean, is it something for civil 3d to allow transactions that work on things such as point styles?
does any of this matter regarding the crashing on copyassibling?
I also tried opening the pointstyle as write instead of read, ut that didn't help
it figures, as soon as I send my last question, I noticed something that did in fact casue my problem. I was suppyling the objectID from a previous operation which was from a PointEntity
Can't find what you're looking for? Ask the community or share your knowledge.