Author Topic: object events  (Read 6607 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
object events
« on: August 27, 2004, 12:13:31 PM »
Okay peeps, I need to create a little vba function. What this should do is cause a piece of text to change when I modify another piece of text. Here's what I have:
Code: [Select]
Seating            Capacity                  Units
TWO'S (30X30)      reactor#               usermod#

several times over. Somehow, the user would also have to supply a number to multiply the usermod# to so the reactor would know what to do. Just had a thought: the reactor# in each individual case would always reference the same multiple, example above # of usermod# x 2 (being two seats per table) would equal reactor#. Therefore, I suppose we could attach the multiple into the code of the event for reactor#? As I write, it begins to feel more complicated.
All I know to do is this:

Code: [Select]
Private Sub AcadDocument_ObjectModified(ByVal Object As Object)

End Sub


I don't know where to begin. Please help?

SpeedCAD

  • Guest
object events
« Reply #1 on: August 27, 2004, 12:44:52 PM »
Hi...

Is more easy from Visual Lisp. But from VBA also it can do. You must add to entity a XDATA and from VBA read these XDATA and update other entity.

I don't give you an example beacuse I don't understand fine.

Meybe you put an image example for I understand it.

daron

  • Guest
object events
« Reply #2 on: August 31, 2004, 09:10:33 AM »
I'm not sure what an image will do. All I want to do is have a piece of text that's looking at another piece of text, then when the text changes that this particular text is looking at, it multiplies. ex. 0 0. The first 0 might have a value related to it like 4. Say there are four seat to a given table. The second 0 is user-changed to 6. Now instead of 0 tables, I have 6 tables. The first 0 knows to multiply its value of 4 by the number that was changed by the user to six, thus changing itself to 24. End result: 0 0 becomes 24 6. I know it will take some upfront work, but I can take care of that with a template and there will only be numbers ever given in these areas, so I'm not too concerned about alpha characters, though I can imagine some instances that could cause a problem. Any help appreciated. Thanks.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
object events
« Reply #3 on: August 31, 2004, 02:11:36 PM »
The data MUST be well defined and several things must be taken care to make sure you do not create problems in the future for yourself.
I would expect that a block with attributes might be the best alternative, at least then a user cannot delete the wrong thing and cause the program to go wacko...

Let me work on a 3 column table with attributes and a reactor to make it effective. If that is acceptable...
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

daron

  • Guest
object events
« Reply #4 on: August 31, 2004, 09:56:54 PM »
That would be great Keith, but let's work on plain text objects if you don't mind. I'm aware that there are problems with this, but you know how the unknowledgeable can be with that dreaded explode command, but then I suppose we could counter that in this too, couldn't we? hehehe.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
object events
« Reply #5 on: August 31, 2004, 10:34:08 PM »
Ok.....
What we need to do is:

a) Associate Seating/Capacity/Unit text with all other text items....
b) React to an object_changed event
c) Change the associated text Capacity by our multiplication factor (stored in our Seating text)

Lets start by defining the XData fields required to keep the text identified with one another.

XData Seating Text
Application Name
Capacity Text Handle
Units Text Handle
Multiplication Factor

XData Capacity Text
Application Name
Seating Text Handle
Units Text Handle

XData Units Text
Application Name
Seating Text Handle
Capacity Text Handle

Now lets get some pseudo code going....
Code: [Select]

object_modified_event
is object text?
No -> exit
Yes -> check for xdata
does xdata exist?
no -> exit
yes -> get application name
is it our application?
no -> exit
yes -> extract handles of associated text items
select all associated items by handle
do all associated items exist?
no -> notify user -> exit
yes -> extract multiplication factor from Description text
extract changed Unit text
convert to a real number
multiply by factor
apply text result to Capacity text


Now we need to build in some fuctionality to do a few tasks that would be a little bit difficult to handle without an object interface ... helper functions ...

Needed Functions
AssociateItems
ModifyMultiplicationFactor
PreventCopy
DeleteAssociated

There is also a lot more required to make it work "effectively" but I think I have covered most of the issues. I'll look at putting together some code tomorrow....Until then, see if you can come up with some on your own...
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

Trev

  • Guest
object events
« Reply #6 on: August 31, 2004, 11:25:18 PM »
Quote from: Daron
That would be great Keith, but let's work on plain text objects if you don't mind. I'm aware that there are problems with this, but you know how the unknowledgeable can be with that dreaded explode command, but then I suppose we could counter that in this too, couldn't we? hehehe.


I have one little question.
If it is done using plain text, (as keith has shown a good working model structure using xdata) if as you mentioned about the unknowledgeable creating the text. The text needs to have the xdata written into it. That will need to be addressed when the text is added to the drawing. So it's possible the unknowledgeable will create plain text (or mtext) without any xdata. How to avoid that problem? AN additional program needs to be written to create the table text. But would user use that program to create in the first place? maybe, maybe not. Thats the hiccup.

So then maybe the attribute method maybe a little better (in a sense) and an event added to check object if exploded.
object.BeginCommand(CommandName)

Oh wait a sec. using Keiths method when testing text for xdata, if no xdata found, "kick user". Open a new dialog to add xdata to object, if user is certain the selected object is the correct one. Of course the other text within the table will have to be selected and have xdata added to them also.

This could be very challenging.

daron

  • Guest
object events
« Reply #7 on: September 01, 2004, 08:40:51 AM »
Thanks guys. I'm going to print off Keith's pseudo-code and see what I can do.

"Kick user"? That's a good one. Maybe we can draw a picture of a boot, add a large piece of text with the loginname of the user and move the boot until it kicks and explodes the username text? What do you think? OR, maybe we get Dent's gorilla drawing to sit on the username text when the explode command in invoked?

Trev

  • Guest
object events
« Reply #8 on: September 01, 2004, 11:47:25 PM »
LOL' Daron, yeah I reckon you should. Then see how long it takes before one of the users jumps up and says "hey whats going on"

ML

  • Guest
object events
« Reply #9 on: September 17, 2004, 10:11:53 PM »
Hey Guys


I was just reading through this and people can be a pain in the * with the explode command.

I was wondering if you could create a document level event that would react to people exploding? I guess if I went to a drawing change event, I could do something?

I am attributing all of our title blocks now in work and I did create an option in the pulldown that will allow users to explode attributes to text, it is simply the burst command.

My thinking was, if you are going to do it, at least do it correctly

How about a reactor that would say," it you explode this text, you computer will explode? Then we can have a ticking wav kick in :)

Mark

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
object events
« Reply #10 on: September 18, 2004, 10:15:47 PM »
Hmmm....
Mark, the reactor you are looking for is "begin_command"
Grab the command name in that reactor, if it is "EXPLODE" then set a global variable in VBA to tell the "end_command" rector that an explode just took place.
You will need to work out a way to determine te block name just exploded so that you can notify the user if the wrong block was exploded.
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