.NET

Reply
Active Contributor
deepa
Posts: 37
Registered: ‎01-10-2007
Message 1 of 11 (103 Views)

Block structure in VB.net

103 Views, 10 Replies
02-13-2007 10:53 PM
How to get the number of levels for nested blocks in VB.net
Distinguished Contributor
Patrick Johnson
Posts: 229
Registered: ‎04-26-2005
Message 2 of 11 (103 Views)

Re: Block structure in VB.net

02-14-2007 08:44 AM 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
Distinguished Contributor
Patrick Johnson
Posts: 229
Registered: ‎04-26-2005
Message 3 of 11 (103 Views)

Re: Block structure in VB.net

02-14-2007 08:45 AM 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
Distinguished Contributor
Patrick Johnson
Posts: 229
Registered: ‎04-26-2005
Message 4 of 11 (103 Views)

Re: Block structure in VB.net

02-14-2007 08:45 AM 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
Distinguished Contributor
Patrick Johnson
Posts: 229
Registered: ‎04-26-2005
Message 5 of 11 (103 Views)

Re: Block structure in VB.net

02-14-2007 08:47 AM 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
Distinguished Contributor
Patrick Johnson
Posts: 229
Registered: ‎04-26-2005
Message 6 of 11 (103 Views)

Re: Block structure in VB.net

02-14-2007 08:55 AM in reply to: deepa
sorry for all the reply's internet problems

pat
Active Contributor
deepa
Posts: 37
Registered: ‎01-10-2007
Message 7 of 11 (103 Views)

Re: Block structure in VB.net

02-15-2007 08:55 PM in reply to: deepa
thanks patrick.but i need the details.can you pls show some examples?
Distinguished Contributor
Patrick Johnson
Posts: 229
Registered: ‎04-26-2005
Message 8 of 11 (103 Views)

Re: Block structure in VB.net

02-17-2007 07:51 AM 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
Active Contributor
deepa
Posts: 37
Registered: ‎01-10-2007
Message 9 of 11 (103 Views)

Re: Block structure in VB.net

02-19-2007 02:43 AM 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.
Distinguished Contributor
Patrick Johnson
Posts: 229
Registered: ‎04-26-2005
Message 10 of 11 (103 Views)

Re: Block structure in VB.net

02-19-2007 01:25 PM 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.