Count blocks add to listbox
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Count blocks add to listbox
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
Ed Jobe
Guest





Posted: Fri Dec 31, 2004 3:18 am    Post subject: Re: Count blocks add to listbox Reply with quote

Sounds like you using OE. You don't have enough threads downloaded. The
search I did was at adesk's http site. It goes all the way back. Use the
seach box here. http://discussion.autodesk.com/forum.jspa?forumID=33, or
google's.

--
----
Ed
----
"Wade" <wnederveld@preinnewhofdonotreply.com> wrote in message
news:41d46d81$1_3@newsprd01...
Quote:
Must be my ng search isn't working, because the only "hits" I receive is
this thread. It doesn't matter if I set either of the "Received before"
or
"Recieved after" dates or leave them blank (uncheck), if I put the "count
block" in the Subject Field or the Message Field or both, I still only get
this thread I even changed the "Look in" field to
"discussion.autodesk.com". I'll try googles search....

Thanks anyway.

"Ed Jobe" <not.edljobe@hotmail.com> wrote in message
news:41d467c8$1_3@newsprd01...
I just did search in this ng for "count block" and got all kinds of
samples.
Looking at the names of the posters, I'm sure you'll find something
useful
right away.

--
----
Ed
----
"Wade" <wnederveld@preinnewhofdonotreply.com> wrote in message
news:41d45dbf$1_3@newsprd01...
OK, thanks.

Being relatively new to Autocad vba, I'm not sure how to do this
(refering
to objects parent and getting parent info). Do you have an example?
(always
looking to learn new stuff)
Thanks.

"Ed Jobe" <not.edljobe@hotmail.com> wrote in message
news:41d45976$1_2@newsprd01...
When I said, "you", I meant you as a programmer. Your code needs to
examine
each block def for nested blocks, then multiply by the parent's
count.

--
----
Ed
----
"Wade" <wnederveld@preinnewhofdonotreply.com> wrote in message
news:41d45559$1_3@newsprd01...
Ed,

Thanks for you input.

I think (just my opinion) it would be easier on the user if the
program
would count the nested blocks inside each block. What if the user
didn't
know how many blocks were in block "A" (like a new employee or if
you
received a drawing from someone outside the company). What if
your
drawing
consisted of blocks A-Z, and blocks 1-99 each of which had
anywhere
from
0
to 2 or 3 nested blocks (and maybe a couple had blocks that were
nested
3
or
4 levels deep - i.e. a faucet block inside a sink block inside a
building
block) - of course a drawing this complicated is very unlikely.
What
you
suggest would work, it just might be harder if the drawing were
very
complicated or the user was unfamilar with the blocks in the
drawing.



"Ed Jobe" <not.edljobe@hotmail.com> wrote in message
news:41d43635$1_1@newsprd01...
Do you need to physically count nested blocks? Shouldn't it just
be
a
multiple of how many times its inserted? e.g. if block A
contains
2
of
block
B and block A is inserted 30 times, then there will be 60 of
block
B.

--
----
Ed
----
"Wade" <wnederveld@preinnewhofdonotreply.com> wrote in message
news:41d434fb_3@newsprd01...
Unfortuately, no, at least not yet.

Does anyone else know how?

"gizmowiebe" <nospam@address.withheld> wrote in message

news:20768832.1104413940191.JavaMail.jive@jiveforum1.autodesk.com...
Thx Wade,

That codes works, but do you know how I can change it to add
blocks
nested
in another block















Back to top
Anne Brown
Guest





Posted: Fri Dec 31, 2004 4:03 am    Post subject: Re: Count blocks add to listbox Reply with quote

As Ed said, you are searching only the messages on your harddrive
from using OE.

The discussion group search engine provides flexibility for
searching through existing message content. To search:

1. Go to http://discussion.autodesk.com/

2. Select a product (Example: AutoCAD which includes VBA)

3. Type your keywords into the search box and click Search. Note:
You can further refine your query by selecting a specific
discussion group from the dropdown provided. Your group choices
will vary in the drop down, based on where you have navigated on
the discussion group site.

Search results are sorted by relevance (a complex query of all
relevant content based on your keywords and group choices).
Clicking on the message result will display the entire thread
(the series of messages and replies). Clicking on the Post date
will sort the results by date with most recent first.
---
Anne Brown
Discussion Groups Administrator
Autodesk, Inc.

Wade wrote:
Quote:

Must be my ng search isn't working, because the only "hits" I receive is this thread. (snip)
Back to top
Matt W
Guest





Posted: Mon Jan 03, 2005 9:10 pm    Post subject: Re: Count blocks add to listbox Reply with quote

This snippet will count the blocks nested within xrefs.
Examine the code and you should be able to figure out how to change it to
search for block within blocks.

Code:

    Dim MyBlkArray() As Variant
    Dim i As Long, j As Long
    Dim count As Integer
    Dim index As Integer
    Dim FoundBlock As Boolean
    Dim entXref As AcadExternalReference
    Dim entBlock As AcadBlock
    Dim entNestedBlock As AcadBlockReference
    Dim ent1, ent2 As AcadEntity

    count = ThisDrawing.ModelSpace.count
    i = 0
    For index = 0 To count - 1
        If ThisDrawing.ModelSpace.Item(index).ObjectName =
"AcDbBlockReference" Then
            j = 1
            FoundBlock = False
            While j <= i
                If MyBlkArray(0, j) =
ThisDrawing.ModelSpace.Item(index).Name Then
                    MyBlkArray(1, j) = MyBlkArray(1, j) + 1
                    j = i
                    FoundBlock = True
                End If
                j = j + 1
            Wend
            If Not FoundBlock Then
                i = i + 1
                ReDim Preserve MyBlkArray(2, i)
                MyBlkArray(0, i) = ThisDrawing.ModelSpace.Item(index).Name
                MyBlkArray(1, i) = 1
            End If
        End If
    Next index

    For Each ent1 In ThisDrawing.ModelSpace
        If TypeOf ent1 Is AcadExternalReference Then
            Set entXref = ent1
            Set entBlock = ThisDrawing.Blocks(entXref.Name)
            For Each ent2 In entBlock
                If TypeOf ent2 Is AcadBlockReference Then
                    Set entNestedBlock = ent2
                    j = 1
                    FoundBlock = False
                    While j <= i
                        If MyBlkArray(0, j) = entNestedBlock.Name Then
                            MyBlkArray(1, j) = MyBlkArray(1, j) + 1
                            j = i
                            FoundBlock = True
                        End If
                        j = j + 1
                    Wend
                    If Not FoundBlock Then
                        i = i + 1
                        ReDim Preserve MyBlkArray(2, i)
                        MyBlkArray(0, i) = entNestedBlock.Name
                        MyBlkArray(1, i) = 1
                    End If
                    j = j + 1
                End If
            Next ent2
        End If
    Next

    Me.ListBoxBlocks.ColumnCount = 2
    Me.ListBoxBlocks.ColumnWidths = "150;36"
    Me.ListBoxBlocks.Column() = MyBlkArray


--
I support two teams: The Red Sox and whoever beats the Yankees.

"gizmowiebe" <nospam@address.withheld> wrote in message
news:20768832.1104413940191.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
Thx Wade,

That codes works, but do you know how I can change it to add blocks nested
in another block


Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB