.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

technique for maintaining drawing objects

4 REPLIES 4
Reply
Message 1 of 5
kcimos
500 Views, 4 Replies

technique for maintaining drawing objects

I'm working on a few projects that will use dynamic blocks that are "associated" with a baseline, or part of a "collection" of baseline based objects. For example a parking lot manager. In this case each parking space will be represented graphically by one dynamic block which will have some parameters controlled by the program, & others by the user (such as label locations), and the baseline will have another block probably with XDATA storing the coords of each space, and a label for the row count, the objectID of each space block "associated" with the baseline, etc, which could be read by the program later for editing purposes.

 

I'm trying to think of ways to manage these blocks. What if the user wants to change the length or shape of the baseline (which will be a polyline)? I basically have the algorithm worked out (erase all of the space blocks, have user edit the pline, recalculate everthing as needed, re-insert all the blocks), but what if someone accidentally erases one of the blocks. That would be bad, very bad. So I could create some event handlers

(per http://through-the-interface.typepad.com/through_the_interface/2010/02/watching-for-deletion-of-a-sp...)

This would be OK, as long as every potential user loaded my program.

I could create nested blocks that would ultimately be inserted into the current drawing, but the user would not be able to edit the parameters that they would need to, such as label locations, which I feel as a user, would be critical. ANd still these blocks that might have all 5 or 1000 spaces in them could be erased. So I that is not a solution.

Creating a custom objectARX object I think would be overkill (I have never done it, so I don't know)

 

Anyone have any ideas on how to maintain a relationship between autocad entities & a vb.net object?

4 REPLIES 4
Message 2 of 5
StephenPreston
in reply to: kcimos

 You want to mark specific entities as being related to your application, and persist that information between sessions? The two ways this is normally done are:

 

1. Mark the entities themselves using Xdata or an Xrecord attached to the entity's extension dictionary

2. Store an Xrecord in the Named Objects Dictionary that holds soft or hard pointer ids to the entities you're interested in.

 

Which you choose depends on your application architecture, and sometimes its more convenient to do both. You could, of course, store this information outside the drawing, by storing the unique combination of drawing path and handle in your external database, but then you have to worry about someone moving the drawing to another location.

 

However, the behavior you're describing - adding a number of blocks with set spacing along a path defined by another entity - sounds like a standard use for the Associative Array feature that was introduced in AutoCAD 2012. Here's a blog post about the API, but (of course) you can do all this through the UI too) -

 

http://through-the-interface.typepad.com/through_the_interface/2011/11/creating-a-simple-associative...

 

Cheers,

Stephen Preston
Autodesk Developer Network
Message 3 of 5
kcimos
in reply to: StephenPreston

an associative path array would not be proper in this situation due to each instance of the block most likely being different with properties set by my routine along with some being available to the user after wards, all while remaining associated with the path. Actually creating associative arrays with vb.net for other purposes is what lead me to the current "more advanced" problem.

 

I will look into the Named Objects Dictionary & XData.

Message 4 of 5
StephenPreston
in reply to: kcimos

BTW You can also create 'update' dependencies between entities using the Overrule API. I show a simple example of this in my Network sample included with my AU presentation on Overrules available here - http://through-the-interface.typepad.com/through_the_interface/2010/12/some-content-from-au-2010.htm...

 

And you can create geometric dependencies yourself as demonstrated in my other presentation in the same post. (Thinking about it - if asociative arrays nearly give you what you need, then setting up your own geometric constraints will probably give you everything you need).

Cheers,

Stephen Preston
Autodesk Developer Network
Message 5 of 5
kcimos
in reply to: StephenPreston

that link doesn't work (page not found)

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost