Message 1 of 3

Not applicable
01-24-2017
10:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here a exemple issu from my below sub :
here the sub :
<CommandMethod("test")> _ Public Shared Sub Test() Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database While (True) Using tr As Transaction = acCurDb.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable acBlkTbl = tr.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) Dim acBlkTblRec As BlockTableRecord acBlkTblRec = tr.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite) Application.SetSystemVariable("OSMODE", 512) Dim prent As PromptEntityOptions = New PromptEntityOptions(vbCrLf & "Specify Entity:") prent.SetRejectMessage("Only BlockReferences Allowed!") prent.AddAllowedClass(GetType(BlockReference), True) Dim rsent As PromptEntityResult = acDoc.Editor.GetEntity(prent) If Not rsent.Status = PromptStatus.OK Then Return Dim pneo As PromptNestedEntityOptions pneo = New PromptNestedEntityOptions("") pneo.NonInteractivePickPoint = rsent.PickedPoint pneo.UseNonInteractivePickPoint = True pneo.AllowNone = True If Not acDoc.Editor.GetNestedEntity(pneo).ObjectId = ObjectId.Null Or IsNothing(acDoc.Editor.GetNestedEntity(pneo).ObjectId) Or IsDBNull(acDoc.Editor.GetNestedEntity(pneo).ObjectId) Then Dim psubent As Entity = tr.GetObject(acDoc.Editor.GetNestedEntity(pneo).ObjectId, OpenMode.ForRead) Dim obj As DBObject = tr.GetObject(psubent.ObjectId, OpenMode.ForRead) 'si choix d'une entité autre que AttributReference --> TableBlockRecord ' sinon Blockreference. Do While Not (TypeOf (obj) Is BlockTableRecord) And Not (TypeOf (obj) Is BlockReference) acDoc.Editor.WriteMessage(vbCrLf & "TypeName : " & TypeName(obj) & " GetRXClass" & obj.GetRXClass.Name.ToString) obj = tr.GetObject(obj.OwnerId, OpenMode.ForRead) Loop acDoc.Editor.WriteMessage(vbCrLf & "FIN - TypeName : " & TypeName(obj) & " GetRXClass" & obj.GetRXClass.Name.ToString) Dim Nom As String = "" Select Case True Case TypeOf (obj) Is BlockTableRecord Nom = CType(obj, BlockTableRecord).Name Case TypeOf (obj) Is BlockReference With CType(obj, BlockReference) Dim objBlocDef As BlockTableRecord = tr.GetObject(.DynamicBlockTableRecord, OpenMode.ForRead) Nom = objBlocDef.Name acDoc.Editor.WriteMessage(vbCrLf & "Nom " & Nom) End With End Select If Nom.Contains("|") Then Dim dec As String() = Split(Nom, "|") acDoc.Editor.WriteMessage(vbCrLf & "Nom du bloc: " & dec(UBound(dec))) Else acDoc.Editor.WriteMessage(vbCrLf & "ce n'est pas un bloc") End If Else 'AcDbBlockReference End If pneo = Nothing End Using End While End Sub
when i select a block i have BlockTableRecord and when selec a attribut i have BlockReference.
How i can retrieve info from all bloc.. Each Bloc have a attribut not visible. Wht i dont have BlockReference when select a block with attribut not visible ?
Can you improve my sub ?
thanks all.
Solved! Go to Solution.