Message 1 of 6
Can not write selected block attributes
Not applicable
01-15-2012
01:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Everybody,
I have a prblem with the code. I posted the code below. I have two questions about the code.
The First in vba there is a function refers to blocks effective name is there ant similar function vb.net has?
Because when I filtered Blocks that I want particularly DYNBlocks I get all of them in vba I inserted
İf blockobject.effectivename=" ..." then
it can solved. but invb.net I did not find a way to get rid of this...
The second question is the code can not able to write attribute when selecting fence mode. In normal selection it did not happen. What am I doing wrong?
Thanks for replies...
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime
Public Class Class1
<CommandMethod("gss")> _
Public Sub gget()
Dim acDocEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim entOpt As PromptEntityOptions = New PromptEntityOptions("select a polyline:")
entOpt.AllowNone = True
Dim spoly As PromptEntityResult = acDocEd.GetEntity(entOpt)
Dim acCurDb As Database = Application.DocumentManager.MdiActiveDocument.Database
Using acTrans1 As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim obj As DBObject = acTrans1.GetObject(spoly.ObjectId, OpenMode.ForWrite)
If TypeOf (obj) Is Polyline Then
Dim poly As Polyline = CType(obj, Polyline)
Dim opt As New Point3d
Dim sel_fence As New Autodesk.AutoCAD.Geometry.Point3dCollection
For ii = 0 To poly.NumberOfVertices - 1
opt = poly.GetPoint3dAt(ii)
sel_fence.Add(opt)
Next
Dim acTypValAr(0) As TypedValue
acTypValAr(0) = New TypedValue(Autodesk.AutoCAD.DatabaseServices.DxfCode.BlockName, "MET-HVZ2,`*U*")
Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr)
Dim sblck As PromptSelectionResult = acDocEd.SelectFence(sel_fence, acSelFtr)
If sblck.Status = PromptStatus.OK Then
Dim acSSet As SelectionSet = sblck.Value
Dim nnstr As String
Dim nn As Integer
nn = 1
For Each acSSObj As SelectedObject In acSSet
Dim acEnt As Entity = acTrans1.GetObject(acSSObj.ObjectId, OpenMode.ForWrite)
nnstr = "H" & nn.ToString
SetAttribute(acSSObj.ObjectId, "HIDRANT_ISIM", nnstr)
nn = nn + 1
Next
acDocEd.WriteMessage("Number of objects selected: " & acSSet.Count.ToString())
Else
acDocEd.WriteMessage("Number of objects selected: 0")
End If
Else
acDocEd.WriteMessage("Selection must be a polyline...")
End If
End Using
End Sub