.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block structure in VB.net

10 REPLIES 10
Reply
Message 1 of 11
deepa
348 Views, 10 Replies

Block structure in VB.net

How to get the number of levels for nested blocks in VB.net
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: deepa

You are going to need to set up a routine that is recursive.

You are going to need to search each blocks table record for blockreferences.

pat
Message 3 of 11
Anonymous
in reply to: deepa

You are going to need to set up a routine that is recursive.

You are going to need to search each blocks table record for blockreferences.

pat
Message 4 of 11
Anonymous
in reply to: deepa

You are going to need to set up a routine that is recursive.

You are going to need to search each blocks table record for blockreferences.

pat
Message 5 of 11
Anonymous
in reply to: deepa

You are going to need to set up a routine that is recursive.

You are going to need to search each blocks table record for blockreferences.

pat
Message 6 of 11
Anonymous
in reply to: deepa

sorry for all the reply's internet problems

pat
Message 7 of 11
deepa
in reply to: deepa

thanks patrick.but i need the details.can you pls show some examples?
Message 8 of 11
Anonymous
in reply to: deepa

here is an example of recursive programming

Public Function GetNestedBlock(ByRef obj1 As ObjectId)
' recursive programming (calling itself)

Using DB As Database = HostApplicationServices.WorkingDatabase
Using Trans As Transaction = DB.TransactionManager.StartTransaction()
Try
Dim bRef As BlockReference = Trans.GetObject(obj1, OpenMode.ForRead)
Dim BTR As BlockTableRecord = Trans.GetObject(bRef.BlockTableRecord, OpenMode.ForRead, True)
Dim ID As ObjectId
'looping thru to grab all the objectid in the table on the block reference
For Each ID In BTR
Dim Ent As Entity = Trans.GetObject(ID, OpenMode.ForRead)
'is the selected entity a block
If TypeOf Ent Is BlockReference Then
Dim BlkRef As BlockReference = Ent
//your code//


GetNestedBlock(BlkRef.Id)
End If
Next
Catch ex As System.Exception
MsgBox(ex.Message)
Finally
Trans.Commit()
Trans.Dispose()
End Try
End Using
End Using

End Function


pat
www.cadenhancement.com
Message 9 of 11
deepa
in reply to: deepa

thanks a lot patrick.but i am not pass the object id i am passing only the block name.
Public Function GetNestedBlock(ByRef blockname As string)
and also i am not clear //your code.

for example Block_abc is having two Levels (blocks) namely Block_123 and Block_xyz.

How can i get the Level of Blocks in nested Block.Pls help me.
Message 10 of 11
Anonymous
in reply to: deepa

I just sent you an example.
\\your code is the area for code to figure out what you are trying to accomplish.

For instance you would want a counter to count the number of levels until you find the block you are looking for


pat
www.cadenhancement.com
Message 11 of 11
deepa
in reply to: deepa

Thank u very much for your help patrick.I am very happy for your advice.

i got it and i coded for your code part(//your code)

ex :// your code

i declared it

dim count as integer

count = count + 1

msgbox(count)

so it returns the nested Block Count.


Once again thanks for your advice .if i make mistake pls advice me.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost