Jump to content

Recommended Posts

Posted

Hi again,

 

I've encountered a new problem and perhaps someone has a good tip of how to solve it.

 

I would like to create an object of some kind that works kind of like a schedule, ie it updates automatically when I change the object it is pointed towards.

 

For those who don't know what I schedule tag is. It is in short a block that extracts specific data from an autocad object, in my case an electrical device. I can create a schedule tag the extracts that name of the device, or its dimensions or whatever.

 

What I want to create is a similar object that count the number of desired objects in a specified space, and updates it automatically. For instance if I add another object of the same kind in the selected space, it automatically updates the count.

 

Is this even possible?

 

(if not for a electrical device I would much appreciate how to do this on simple blocks as well)

Posted

Sorry I don't have a solution but I'm sure it's possible.

Just taking out the automatic feature for a bit (the hard bit - which may be done with a reactor), I imagine it'd just involve using ssget based on a window or fence with a filter on specified blocks. I've never used ssget with window though so someone else will have to give it a go for you....

Posted
Hi again,

 

I've encountered a new problem and perhaps someone has a good tip of how to solve it.

 

I would like to create an object of some kind that works kind of like a schedule, ie it updates automatically when I change the object it is pointed towards.

 

For those who don't know what I schedule tag is. It is in short a block that extracts specific data from an autocad object, in my case an electrical device. I can create a schedule tag the extracts that name of the device, or its dimensions or whatever.

 

What I want to create is a similar object that count the number of desired objects in a specified space, and updates it automatically. For instance if I add another object of the same kind in the selected space, it automatically updates the count.

 

Is this even possible?

 

(if not for a electrical device I would much appreciate how to do this on simple blocks as well)

 

 

Look into Tables command in acad. When you add a block listed in the table, A balloon in the right corner will popup letting you know that the Table needs to be updated. When you click this balloon the table in the drawing will be automatically udated.

Posted

I didn't fully understand how to use table, but what I could figure out this command count all block inside a drawing. I want to count only those block that are within a selection area (eg window, WP, cross etc)

 

Maybe I didn't understand tables though?

Posted

Does this help you? (Let me know if you want explanations)

(defun c:cntBlks (/ blkName pt1 pt2 ss)
 (Cond ((not (and (setq blkName (entsel "\nSelect block to count: "))
          (setq blkName (cdr (assoc 2 (entget (car blkName)))))))
    (princ "\nError selecting block."))
   ((not (and (setq pt1 (getpoint "\nSpecify top left of area: "))
          (setq pt2 (getpoint "\nSpecify bottom right of area: "))))
    (princ "\nPoints not selected."))
   (T
    (setq ss (ssget "_W" pt1 pt2 (list (cons 2 blkName))))
    (princ (strcat "\nNumber of blocks in window: " (itoa (sslength ss))))
    )
   )
 (princ)
)

Posted

thanks steve1!

 

This was useful at least from a learning perspective, but unfortunately not what I'm trying to achieve.

 

Consider this scenario.

 

I place x number of electrical outlets in a room within a house. Now I want to create a text that counts this number of electrical outlets inside the room and returns "x number of electrical outlets".

 

This is fairly straightforward, and I was able to create this routine, although not very similar to what Steve1 proposed.

 

However, this is where I want the magic to kick in.

 

If I add or remove an electrical outlet inside this room, the text should change itself, preferbly through a command, cause I would assume a constant loop is not recommendable, and now returning "x+change in number of blocks number of electrical outlets".

 

As I write this text I think I just realized how to achieve this, will return after I've tried this...

Posted

We're all learning here :) I'm interested to see what you come up with, though I think you'll need a reactor to trigger the lisp to count the number of blocks (if such a reactor exists ??). But yeah, if you find another way then I'm sure I'll learn something...

 

Btw, if you just want to update the text by a command, the static data you'll need is the text handle (dxf code 5), the block name and the dimensions of the window to search in. Then you wouldn't need to select or pick anything.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...