Author Topic: Diesel Expression for a block count  (Read 10469 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
Re: Diesel Expression for a block count
« Reply #15 on: October 11, 2005, 11:53:50 AM »
Will,
FYI
That will fail if there are no such block in the drawing.
Yeah, I know it will fail under the proper circumstances.  I just wanted something lean and mean.

Here is a few pictures of the block:
« Last Edit: October 11, 2005, 11:57:20 AM by whdjr »

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Diesel Expression for a block count
« Reply #16 on: October 11, 2005, 12:01:23 PM »
This is what I was going to use and just pass it the name of my block so that I could use it in other places.
Code: [Select]
(defun c:bcount (str)
  (rtos
    (sslength (ssget "x" (list '(0 . "INSERT") (cons 2 str))))
    2
    0
  )
)

try this...

Code: [Select]
(setq str (getstring "Block name : "))
(if str
  (progn
(setq str1 (ssget "X" (list (cons 0 "INSERT") (cons 2 str))))
(alert (strcat "You have " (rtos (sslength str1)) " of " str ))
))
Keep smile...

whdjr

  • Guest
Re: Diesel Expression for a block count
« Reply #17 on: October 11, 2005, 12:18:55 PM »
You can't input that in a block.

I want it to be generic so if I have that block in a plan 5 times and 3 times there are 5 lockers and 2 times there are 10 lockers then it will give the correct count in the text for each block.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Diesel Expression for a block count
« Reply #18 on: October 11, 2005, 01:57:35 PM »
You can't input that in a block.

why not ?
Keep smile...

whdjr

  • Guest
Re: Diesel Expression for a block count
« Reply #19 on: October 11, 2005, 03:24:26 PM »
How are you going to put your routine in a block so that it updates as the block updates?

I would like to know how because I have yet to see it done.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Diesel Expression for a block count
« Reply #20 on: October 11, 2005, 04:15:32 PM »
Will, what type of object is your locker block? You could do something really simple with an object reactor similar to what Luis did with the persistent lisp. Once it is loaded, all you need to so is update the block and let the persistent lisp program do the rest.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

whdjr

  • Guest
Re: Diesel Expression for a block count
« Reply #21 on: October 11, 2005, 04:41:33 PM »
I have never written a reactor so I would have to look into that.

Will a reactor keep the count seperate if the block is inserted multiple times in a dwg?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Diesel Expression for a block count
« Reply #22 on: October 11, 2005, 07:08:06 PM »
I have never written a reactor so I would have to look into that.

Will a reactor keep the count seperate if the block is inserted multiple times in a dwg?
It depends on how you implement the reactor ... the reactor is simply a program ... you can have the reactor attached to a specific block, thus when that block is edited, the reactor will fore for that particular block. Of course it all means nothing if you explode the block ...

I developed a program for church pews some time ago, while it didn't use reactors, it did allow the user to edit the blocks individually, thus you could extend or trim the block and the associated attribute would update.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Diesel Expression for a block count
« Reply #23 on: October 11, 2005, 09:13:35 PM »
How are you going to put your routine in a block so that it updates as the block updates?

I would like to know how because I have yet to see it done.


Wh....   i'm trying to understand what exactly you need to do.
Yes you can't put entire code in a block
but you can use variable on it.

also,

the eattext can do your block count..(if your block was created to insert block depending the length)
otherwise you can use reactor or make your lisp dependind the block size.

You can also use invisible attribute can allow to count your block.
depending exactly what you need to do with it.
need more info... :-o
Keep smile...

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Diesel Expression for a block count
« Reply #24 on: October 12, 2005, 09:47:45 AM »
Will,

So you need text in a drawing that always has the current number for a certain amount of blocks?

If so, couldn't you just put the text in the drawing on a specific layer or add xdata or both (so you can filter it later).

Then at startup run your (ssget "x" '((....))) and update the value of your text.

Just thinking out loud here.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

whdjr

  • Guest
Re: Diesel Expression for a block count
« Reply #25 on: December 14, 2005, 02:58:13 PM »
Ok here's an update guys.  The other day I was on the Autodesk newsgroups and I was watching some of the posts for DB's and I noticed one similar to mine.  the guy with the solution recommended to the other guy to use a dimension for the counting.  Turn off all the linework for the Dim.  Then you have the text and it is already set up for a prefix or a suffix.  I thought that was ingenius.


That truely was thinking outside the box(or getting below the surface). :-)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Diesel Expression for a block count
« Reply #26 on: December 14, 2005, 03:08:35 PM »
Ingenious indeed ... if your lockers are 12" each, simply make the linear dimension scale 1/12th, set the units to decimal, no trailing or leading zeros, precision set to whole numbers, and add your custom prefix or suffix ... should do nicely ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie