How to Retrive a geometry wall bypass analytics ?

How to Retrive a geometry wall bypass analytics ?

sizy458
Advocate Advocate
1,199 Views
8 Replies
Message 1 of 9

How to Retrive a geometry wall bypass analytics ?

sizy458
Advocate
Advocate

Hello,

I am developing on Revit and I would extract geometry of a wall hosted in the linker document 'RevitLinkInstance'.

How bypassing analytics function, to read the geometry of a wall hosted in the RevitLinkInstance without taking account openings (doors, windows) ??
I need to determine if a wall of a rectangular rvt link or not ?.

Thank you

 

Bonjour,

Je développe en ce moment sur Revit et je voudrais extraire la géométrie d'un mur d'un document linker , je
veux dire extraire la géométrie d'un mur d'un lien RVT (RevitLinkInstance).

Je me suis fait une fonction :

Cette fonction me retourne bien la géométrie mais  prend en compte les portes et fenêtres qui débordent du mur.
Comment sans passer par l'analytics ,pouvoir lire la géométrie d'un mur (hosted dans un RevitLinkInstance)  sans prendre compte les ouvertures (portes ,fenêtres)   ??
j'en ai besoin pour déterminer si un mur d'un lien rvt est rectangulaire ou non .

Merci

0 Likes
1,200 Views
8 Replies
Replies (8)
Message 2 of 9

jeremytammik
Autodesk
Autodesk

Dear Sizy458, bonjour,

 

As I already suggested to you, I would take a look at the temporary transaction trick:

 

http://thebuildingcoder.typepad.com/blog/2015/03/findinserts-retrieves-all-openings-in-all-wall-type...

 

http://thebuildingcoder.typepad.com/blog/2012/10/the-temporary-transaction-trick-for-gross-slab-data...

 

You can use that to temporarily delete or modify BIM elements, retrieve some data, and roll back the transaction to restore the original state.

 

I hope this helps.

 

Merci!

 

Cordialement,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 9

sizy458
Advocate
Advocate

OK,

Thank. But how do i make if the document is a 'RevitLinkInstance' "a link rvt"

about start transaction and "Rollback" ?

0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Good question.

 

You need to obtain the Document instance for the linked document and open the transaction on that.

 

You may be able to get it from the Application object list of documents, or directly from the linked element Document property.

 

Good luck, and please let us know how it goes!

 

Thank ylou!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 9

sizy458
Advocate
Advocate

This code don't work ,i want delete the opening hosted in the wall which hosted in the revitlinkinstance.

Le code ne fonctionne pas je voudrais effacer les ouvertures d'un mur hoster sur un revitlinkinstance

 

 

[Transaction(TransactionMode.Manual)]
     public class CommandTest7 : IExternalCommand
     {

         public Result Execute(
           ExternalCommandData commandData,
           ref string message,
           ElementSet elements)
         {
             UIApplication uiapp = commandData.Application;
             UIDocument uidoc = uiapp.ActiveUIDocument;
             Application app = uiapp.Application;
             Document doc = uidoc.Document;

             Document out_doc = null;
             RevitLinkInstance out_ref = null;
             Reference pickedRef = null;
             Element ee = null;
             Selection sel = uidoc.Selection;
             GroupPickFilter selFilter = new GroupPickFilter();
             /*Tcm cm = new Tcm();
             Element ee = cm.saisirelement(uidoc,ref out_doc,ref out_ref);*/
             pickedRef = sel.PickObject(ObjectType.PointOnElement, selFilter,
             "Please select a element");
             if (pickedRef != null)
             {
                 Element elem = doc.GetElement(pickedRef);
                 RevitLinkInstance rl = elem as RevitLinkInstance;
                 if (rl != null)
                 {
                     out_ref = rl;
                     Document linkedDoc = rl.GetLinkDocument();
                     Element inelem = linkedDoc.GetElement(pickedRef.LinkedElementId);
                     out_doc = linkedDoc;
                     ee = inelem;
                 }
                 else
                 {
                     out_doc = doc;
                     ee = elem;
                 }
             }
             if (ee is Wall)
             {
                 Wall w = ee as Wall;
                 IList <ElementId> ss=w.FindInserts(true, true, true, true);
                 Transaction trans = new Transaction(out_doc);
                 trans.Start("MyEvent"); //crash exception here
                 out_doc.Delete(ss);
                 trans.Commit();
             }
             return Result.Succeeded;
}
}

 

0 Likes
Message 6 of 9

jeremytammik
Autodesk
Autodesk

Dear Sizy458, bonjour,

 

You say, "crash exception here".

 

What is the exact exception message, please?

 

Since I do not see any obvious errors with your code, I may need to pass this on to the development team.

 

That will require a minimal reproducible case:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Can you put that together, please?

 

Thank you!

 

Merci!

 

Cordialement,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 9

sizy458
Advocate
Advocate

I have exception error.

Exception:

"Transactions can only be used in primary documents(projets or families)."

Exception in the transaction's constructor.

thank.

0 Likes
Message 8 of 9

Anonymous
Not applicable

 

oops... mistake.

0 Likes
Message 9 of 9

jeremytammik
Autodesk
Autodesk

Dear Sizy458, bonjour,

Aha.

That is very interesting!

That means that the method you are using to obtain the document and set the out_doc variable is not considered a 'primary' document.

In that case, please go to the Application object and ask it for the document from its list of active documents.

If it is lnot listed, then try opening the document via Application.Open...

Good luck!

Cordialement,

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes