Author Topic: Counting Blocks  (Read 19767 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Re: Counting Blocks
« Reply #15 on: April 11, 2007, 11:04:15 AM »
Luke: you can turn off the borders of the table so you don't see the individual cells.

ML

  • Guest
Re: Counting Blocks
« Reply #16 on: April 11, 2007, 11:19:38 AM »

I may be repeating something that has already been mentioned in this post but I tried bcount and it is really cool but I noticed that it only seems to address Block (inserted) references but it does seem to break them down between paper and Model. It does not seem to address Block Definitions.

I have a VBA module I would be glad to share if it would help anyone.

It gives you Block references in Model, Paper and Block Table Definitions in the drawing.

Mark

Luke

  • Guest
Re: Counting Blocks
« Reply #17 on: April 11, 2007, 12:08:48 PM »
Mark,

The code:
cnt (1- (itoa (sslength ss)))

Results in the following:
ERROR: bad argument type: numberp: "3"

Any thoughts?



ML

  • Guest
Re: Counting Blocks
« Reply #18 on: April 11, 2007, 12:11:58 PM »

Not sure Luke, sorry  :-(

Luke

  • Guest
Re: Counting Blocks
« Reply #19 on: April 11, 2007, 12:16:59 PM »
Sorry, I was hoping Mark Thomas who gave me the code might be able to help. 

Thanks,
Luke

ML

  • Guest
Re: Counting Blocks
« Reply #20 on: April 11, 2007, 12:19:07 PM »

What is the code suppose to do?

Mark

Luke

  • Guest
Re: Counting Blocks
« Reply #21 on: April 11, 2007, 12:19:58 PM »
ML, not sure if you read any of the posting above this but it pretty much explains it all in great detail.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Counting Blocks
« Reply #22 on: April 11, 2007, 12:42:47 PM »
Mark,

The code:
cnt (1- (itoa (sslength ss)))

Results in the following:
ERROR: bad argument type: numberp: "3"

Any thoughts?




Try this:
(itoa (1- (sslength ss)))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Luke

  • Guest
Re: Counting Blocks
« Reply #23 on: April 11, 2007, 12:45:52 PM »
Nailed it!  Thanks a ton!

Crank

  • Water Moccasin
  • Posts: 1503
Re: Counting Blocks
« Reply #24 on: April 11, 2007, 12:53:14 PM »
You can also do this in diesel:
Code: [Select]
$(-,$(getenv, blk_count),1)
Vault Professional 2023     +     AEC Collection

Luke

  • Guest
Re: Counting Blocks
« Reply #25 on: April 11, 2007, 01:07:48 PM »
So just to be clear here Crank, you would continue using the original code but your Diesel Expression would subtract 1?

ML

  • Guest
Re: Counting Blocks
« Reply #26 on: April 11, 2007, 01:10:06 PM »


I'm sorry
I would use VBA to get the same results but it would probably result in more code

Mark

ML

  • Guest
Re: Counting Blocks
« Reply #27 on: April 11, 2007, 01:19:40 PM »

If you put this code in a Sub Module and run it, you will get the count for Blocks and Block References
Mark

Code: [Select]
Sub Blocks_Count()

Dim Blks As AcadBlocks
Dim BLCollect As AcadSelectionSet
Dim GCode(0) As Integer
Dim GData(0) As Variant
Dim GPCode As Variant
Dim GPData As Variant

Set Blks = ThisDrawing.Blocks

GCode(0) = 0
GData(0) = "Insert"
GPCode = GCode
GPData = GData
 Set BLCollect = ThisDrawing.SelectionSets.Add("BLOCKREFS")
BLCollect.Select acSelectionSetAll, , , GPCode, GPData
 MsgBox "There are " & Blks.Count & " blocks in this drawing and", vbInformation, "Blocks"
 MsgBox BLCollect.Count & " Block References", vbInformation, "Block References"
 'MsgBox "There are " & ThisDrawing.Blocks.Count & " block(s) in the block table and " & BLCollect.Count & " blocks inserted (Blockref) in the drawing", vbInformation, "Block Information"
BLCollect.Delete
 Set BLCollect = Nothing
 
End Sub

Quote
Thanks to Keith for the help in writing this

Crank

  • Water Moccasin
  • Posts: 1503
Re: Counting Blocks
« Reply #28 on: April 11, 2007, 01:46:38 PM »
So just to be clear here Crank, you would continue using the original code but your Diesel Expression would subtract 1?
That's what it does. But lisp is also ok.

With diesel you can minipulate the routine for each situation. Now you want to substract 1, but the next time you perhaps need the exact amount.
Vault Professional 2023     +     AEC Collection

Luke

  • Guest
Re: Counting Blocks
« Reply #29 on: April 11, 2007, 01:48:08 PM »
Yes I see, I like that better.  I likt the idea of only having 1 lisp, afterall I have to have a different diesel for each block / field I want to update.

Thank you all for you help!