Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block Count Field?

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
2787 Views, 11 Replies

Block Count Field?

In AutoCAD 2010 is there a way to link a Field to quantity of a certain
Block name in the current drawing?

Paul
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: Anonymous

I wish!

"A+P" wrote in message news:6329823@discussion.autodesk.com...
In AutoCAD 2010 is there a way to link a Field to quantity of a certain
Block name in the current drawing?

Paul
Message 3 of 12
Anonymous
in reply to: Anonymous

I'm trying to think if there's no workaround for this limitation. A field
can be linked to some custom AutoLISP variable, so maybe using a reactor
which will trigger when a certain block is inserted, this variable could be
incremented and the field will reflect the change. So far, it seems
feasible.

--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


"A+P" a écrit dans le message de news:
6329823@discussion.autodesk.com...
In AutoCAD 2010 is there a way to link a Field to quantity of a certain
Block name in the current drawing?

Paul
Message 4 of 12
Anonymous
in reply to: Anonymous

That could get nasty with nested block insertions. You'd have
to monitor the insertion of every block and step through all
subentities each time an insertion occurs. Doable but dang
that's seems to be a lot of overhead.

I don't see why Autodesk could not add a 'count' property to
the block definition object.


"Some Buddy" wrote in message news:6329845@discussion.autodesk.com...
I'm trying to think if there's no workaround for this limitation. A field
can be linked to some custom AutoLISP variable, so maybe using a reactor
which will trigger when a certain block is inserted, this variable could be
incremented and the field will reflect the change. So far, it seems
feasible.
Message 5 of 12
Anonymous
in reply to: Anonymous

Man, this would be so cool. I would love to hear from some of the programming gurus on this subject. This would quickly become one of my favorite tools.
Message 6 of 12
Anonymous
in reply to: Anonymous

I'm not sure what you would use if for but if you have AutoCAD Architecture,
the scheduling feature would do this.

Otherwise some sort of reactor application should be able to monitor this
stuff. In addition, data extraction should work to get some of this
information.

"A+P" wrote in message
news:6329823@discussion.autodesk.com...
In AutoCAD 2010 is there a way to link a Field to quantity of a certain
Block name in the current drawing?

Paul
Message 7 of 12
Anonymous
in reply to: Anonymous

I thought about data extraction but that sure seems like
quite a few clicks to get a simple count.

(vlax-get blockObject 'count) would be much easier.

"Doug Broad" wrote in message news:6329987@discussion.autodesk.com...
> In addition, data extraction should work to get some of this information.
Message 8 of 12
Anonymous
in reply to: Anonymous

I was thinking command reactor here but I'm guessing you could
use a database reactor and avoid the extra overhead?

"Jason Piercey" wrote in message news:6329878@discussion.autodesk.com...
> That could get nasty with nested block insertions. You'd have
> to monitor the insertion of every block and step through all
> subentities each time an insertion occurs.
Message 9 of 12
Anonymous
in reply to: Anonymous

The thing about fields and schedules is that they are automated and can
present information without programming. (sslength (ssget "x" '((0 .
"insert")(2 . "blockname")))) would get all the inserts in all the layouts
but determining the actual count for a particular purpose might be more
complex.

With your example for instance, should it include all layouts or only the
current layout? Should it include references in other block definitions or
should it also multiply those by the number of references to those assembly
block definitions and consider all kinds of other nesting possibilities.
Quickly the idea of simple is gone. Now imagine that we are really needing
AutoCAD to continuously monitor all nesting possiblities of all blocks by
making it a property of all block definitions. That would require quite a
performance hit with little real return to most users.

;-)

"Jason Piercey" wrote in message
news:6330279@discussion.autodesk.com...
I thought about data extraction but that sure seems like
quite a few clicks to get a simple count.

(vlax-get blockObject 'count) would be much easier.

"Doug Broad" wrote in message
news:6329987@discussion.autodesk.com...
> In addition, data extraction should work to get some of this information.
Message 10 of 12
Anonymous
in reply to: Anonymous

For my purposes, it's always a modelspace count so layouts are not
of concern but you do raise a good point. Yes on the nesting, IMO.
After all, if nesting didn't need to be accounted for, a simple ssget
filter does the trick easily enough.

Since when is Autodesk *really* concerned about "performance hits"?
Layer Palette anyone?

;)


"Doug Broad" wrote in message news:6330386@discussion.autodesk.com...
The thing about fields and schedules is that they are automated and can
present information without programming. (sslength (ssget "x" '((0 .
"insert")(2 . "blockname")))) would get all the inserts in all the layouts
but determining the actual count for a particular purpose might be more
complex.

With your example for instance, should it include all layouts or only the
current layout? Should it include references in other block definitions or
should it also multiply those by the number of references to those assembly
block definitions and consider all kinds of other nesting possibilities.
Quickly the idea of simple is gone. Now imagine that we are really needing
AutoCAD to continuously monitor all nesting possiblities of all blocks by
making it a property of all block definitions. That would require quite a
performance hit with little real return to most users.

;-)
Message 11 of 12
Anonymous
in reply to: Anonymous

Actually I was thinking about something like :vlr-beginInsert, but I think
that :vlr-objectAppended would do the trick also.

--
Humans are born with a wide horizon.
As time goes by, the horizon narrows and
narrows, until it becomes a point of view.


"Jason Piercey" a écrit dans le message de news:
6330260@discussion.autodesk.com...
I was thinking command reactor here but I'm guessing you could
use a database reactor and avoid the extra overhead?

"Jason Piercey" wrote in message
news:6329878@discussion.autodesk.com...
> That could get nasty with nested block insertions. You'd have
> to monitor the insertion of every block and step through all
> subentities each time an insertion occurs.
Message 12 of 12
Anonymous
in reply to: Anonymous

;;a possibility???
;;It can be done if you use a lisp variable as a custom field...

;1;;create custom field lets call it MYBLOCKCOUNT (using lisp below).this guy is good.

;;;CADALYST 09/04 Tip1978: SFLD.LSP Create Custom Fields (c) 2004
;;;;Leonid ;Nemirovsky

(defun c:sfld (/ ftitle fauthor fsubject fproj infoobj num num1 deside deside1 deside2 fld fldv pop)
(vl-load-com)
(setq FTITLE " ")
(setq FAUTHOR " ")
(setq FSUBJECT " ")
(setq FPROJ " ")

(setq infoObj (vla-get-SummaryInfo (vla-get-activeDocument (vlax-get-acad-object))))
(vla-put-Title infoObj FTITLE)
(vla-put-Author infoObj FAUTHOR)
(vla-put-Subject infoObj FSUBJECT)
(vla-put-KeyWords infoObj FTITLE)
(vla-put-Comments infoObj FPROJ)

(setq num (vla-NumCustomInfo infoObj))
(if
(> num 0)
(progn
(setq num1 (rtos num 2 0))
(setq question (strcat "You have " num1 " CUSTOM FIELDS do you want to preview them? : "))
(initget 1"Yes No")
(setq deside1 (getkword question))
(if (= deside1 "Yes")(command "dwgprops"))
)
)
(initget 1 "Yes No")
(setq deside2 (getkword "\nDo you want create custom FIELD? : "))
(if (= deside2 "No")(quit))

(while
(setq FLD (getstring T "\nField NAME : "))
(if (= fld "")(setq fld "XXX"))
(setq FLDV(getstring T "\nField VALUE : "))
(if (= fldv "")(setq fldv "XXX"))
(vla-addCustomInfo infoObj FLD FLDV)
(setq pop (strcat "%<\\AcVar CustomDP." fld ">%"))
(setq PT (getpoint "\nField Insertion Point: "))
(command"mtext" pt "w" "0" pop "")
(initget 1 "Yes No")
(setq deside (getkword "\nDo you want create another custom FIELD? : "))
(if (= deside "No")(quit))
)

(princ)
)



;;;;;;;;;;;;
;;;2....THEN RUN THIS SMALL LISP CHANGE MYTHINGIECOUNT
;; to whatever block you want to count
;;all done..
;;regen drawing
;;THE bad part is that you have to run the lisp every time to get the correct
;;;;count back into the lisp variable field.
;;other then that ...i don't know maybe a reactor.?? i've never worked
;;;;with them but they can be somewhat dangerous if
;;you don't know totally what you are doing..;



(defun C:THINGCOUNT ()
(setvar "cmdecho" 0)
(setq sa (ssget "x" (list (cons 0 "INSERT")(cons 2 "MYTHINGIECOUNT")(cons 410 "Model"))))
(setq MYBLOCKCOUNT (sslength sa))
(princ)
) Edited by: msclout72 on Feb 9, 2010 8:48 AM

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

Post to forums  

Autodesk Design & Make Report

”Boost