Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete Object and Place Another in its place fails

3 REPLIES 3
Reply
Message 1 of 4
tgates
256 Views, 3 Replies

Delete Object and Place Another in its place fails

I have an application I am building which places families onto grid lines. I approached the project by writing it as macros first. The macro code works great. Now I want to be able to check for existing families that have been placed by the macro so that I can delete them before placing another set of new ones. This is so that if the grids change the user can get a fresh set of families.

 

The problem I am running into is if I delete the families and then place new ones in their place it doesn't delete the families and I get the error about multiple families occupying the same location. My code to delete the families works great on its own, but when I try to run it within the other code that places the families it fails to delete them.

 

Is this something to do with how I am running transactions? I have tried putting the delete code in its own transaction and as a subtransaction, but neither work.Is there something that I need to do in order to get the objects deleted and the document to update before moving on to add the new families in the same location?

 

I can post code if needed, but I know the code for creation and deletion both work seperately. Just need some advice on why the deletion doesn't work when they are together.

 

 

3 REPLIES 3
Message 2 of 4
peterjegan
in reply to: tgates

Maybe add doc.Regenerate() between delete and new placement?
Message 3 of 4
tgates
in reply to: peterjegan

I thought Transactions automatically call a document.regenerate. So it should automatically regenerate after I commit the transaction.

 

I tried to use TransactionGroup to create a group and seperate Transactions for the deletion part and the creation part. This didn't work either. I am not sure where else to look to figure out why deleting an object and then creating an object in the same exact place fails.

 

 

Message 4 of 4
gopinath.taget
in reply to: tgates

Hello,

 

Sorry to be persistent but did you try explicitly calling doc.Regenerate? Just wanted to make sure. From what you say, if you have two commands, one to delete and another to place again, it is working. So it does look like a regeneration issue.

 

Best Regards

Gopinath

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


Rail Community