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

Sanity Check on Impossible Request

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
CallMeJames
369 Views, 5 Replies

Sanity Check on Impossible Request

I need a sanity check on a user's (hopefully not) impossible request.

 

I've developed a few routines that start when double-clicking on a block, display the appropriate form, and then rebuild the block according to the form information (I delete all entities in the BlockRecord and add as required).

 

It all works great when there's only one copy of the block in the drawing.  Now I'm being asked to make it update only the selected instance of the block.  I've tried anonymous blocks but if the user copies the existing anonymous block, it's no longer unique.  Creating a dynamic block programmatically isn't really possible yet (fyi: I'm in 2013) and having a dynamic block with 30+ visibility states when I might be using 3 max just isn't feasible.  Attributes alone also don’t solve my issue.

 

So…is it possible to have multiple copies of a block that I can update independently via the .Net API but all copies of the block have the same name?

5 REPLIES 5
Message 2 of 6
SENL1362
in reply to: CallMeJames

No, it wouldn't be a reference to the same block.
Can't you do name with a kind of unique suffix?
Or look for a Xref kid of sollution
Message 3 of 6
CallMeJames
in reply to: SENL1362

I can create a unique copy of the block with a different name but it won't stop the user from copying the existing block and assuming they're separate.

Message 4 of 6
JohnDutz
in reply to: CallMeJames

Just thinking off the cuff here, you could embed the block reference ObjectId in the block definition, xdata or a dictionary, and do a lookup.  When the user double-clicks a block and the ObjectId doesn't match the one that is stored for that particular block definition, create a new block definition and replace the block that the user double-clicked...

 

Not sure if that makes sense, it's late.

Message 5 of 6
C_Witt
in reply to: JohnDutz

Or get the block name when doubleclicked and check if there is more than 1, if there is rename them all as required and then edit the target block?

Message 6 of 6
CallMeJames
in reply to: C_Witt

Figured it out!  What finally worked is the following steps:

 

  • Clone the original BlockTableRecord (not a deep clone),
  • Loop through the entities in the original BlockTableRecord, clone each one and append it to the new BlockTableRecord,
  • Set the new BlockTableRecord name to the old root name plus a GUID,
  • Insert the new BlockReference into the current space,
  • Set the new BlockReference's layer and insertion point to the original block's values
  • Delete the original BlockReference.

Thanks to everyone who helped with this.

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