Hello Gentlemen, I need help here please. Code below change the Dynamic block distance Property for 40 Objectid in the collection , which passed to it. it is slow. I need a better idea or faster process here. It is working though. Just need to be touched and I don't know whether is my code or that is the way it should be . Here is the Sub.
Thanks in Advance.
Public Sub vns_Change_visual_Dyn_Blk_Leg_Dimension_On_Drawing(ByVal MyobjIdcol As ObjectIdCollection, ByVal DynDistance() As Double, ByVal Barsize As String) Dim mydwg As Document = Application.DocumentManager.MdiActiveDocument Dim MYed As Editor = mydwg.Editor Dim myDB As Database = mydwg.Database Using Tr As Transaction = myDB.TransactionManager.StartTransaction() Try For Each MyObjIditm In MyobjIdcol Dim myBR As BlockReference = CType(Tr.GetObject(MyObjIditm, OpenMode.ForRead), BlockReference) Dim myBTR As BlockTableRecord = DirectCast(Tr.GetObject(myBR.DynamicBlockTableRecord, OpenMode.ForWrite), BlockTableRecord) Dim myBRC As DynamicBlockReferencePropertyCollection = myBR.DynamicBlockReferencePropertyCollection For Each myBRP As DynamicBlockReferenceProperty In myBRC Select Case myBRP.PropertyName Case "Distance1" If DynDistance(1) <> Nothing Then myBRP.Value = DynDistance(1) End If Case "Distance2" If DynDistance(2) <> Nothing Then myBRP.Value = DynDistance(2) End If Case "Distance3" If DynDistance(3) <> Nothing Then myBRP.Value = DynDistance(3) End If Case "Distance4" If DynDistance(4) <> Nothing Then myBRP.Value = DynDistance(4) End If Case "Distance5" If DynDistance(5) <> Nothing Then myBRP.Value = DynDistance(5) End If Case "Distance6" If DynDistance(6) <> Nothing Then myBRP.Value = DynDistance(6) End If Case "Distance7" If DynDistance(7) <> Nothing Then myBRP.Value = DynDistance(7) End If Case "Distance8" If DynDistance(8) <> Nothing Then myBRP.Value = DynDistance(8) End If Case "Distance9" If DynDistance(9) <> Nothing Then myBRP.Value = DynDistance(9) End If Case "Distance10" If DynDistance(10) <> Nothing Then myBRP.Value = DynDistance(10) End If Case "Distance11" If DynDistance(11) <> Nothing Then myBRP.Value = DynDistance(11) End If Case "Distance12" If DynDistance(12) <> Nothing Then myBRP.Value = DynDistance(12) End If Case "Visibility1" If Barsize <> "" Then myBRP.Value = Barsize End If Case Else ' MYed.WriteMessage("Propert Name : {0} = {1} ", myBRP.PropertyName, myBRP.Value) End Select Next Next Tr.Commit() Catch ex As Exception MsgBox("ERROR IN SET PARAMS TO DYN BLOCK " & ex.Message) End Try End Using End Sub
Check your post please
Cheers 🙂
Not Sure about faster. But you can write it with less code.
Dim bolCheck As Boolean
For i As Integer = 1 To 12
If myBRP.PropertyName = "Distance" & i.ToString Then
If DynDistance(i) <> Nothing Then
myBRP.Value = DynDistance(i)
bolCheck = True
Exit For
End If
End If
If myBRP.PropertyName = "Visibility1" Then
If DynDistance(i) <> Nothing Then
myBRP.Value = Barsize
bolCheck = True
Exit For
End If
End If
Next
If Not bolCheck Then
' MYed.WriteMessage("Propert Name : {0} = {1} ", myBRP.PropertyName, myBRP.Value)
End If
Thanks for Reply .
In a duo core 2 , 2 Hz. it takes about 10 seconds. I don't want to Write a Meter for 10 seconds . But it annoying for user.
Thanks arcticad, that was smart. I used it . Not the code is less messy . But didn't change the speed.
I need to learn a lot.
Again thanks for your time.
10 seconds isn't great, but it's not horrible either. You don't have to build a progress meter, you could just send some text to the editor saying "Processing Blocks..."
-Mark P.
You are great . My brain work solid and is not creative I use what I learn . I noticed adding progress meter add another 1 second to process. But
sending a waiting message to editor is good. Thank you sir. I took that.