The TakeoffFitting I create via Revit API replaced by revit in background?why?

The TakeoffFitting I create via Revit API replaced by revit in background?why?

Anonymous
Not applicable
435 Views
2 Replies
Message 1 of 3

The TakeoffFitting I create via Revit API replaced by revit in background?why?

Anonymous
Not applicable

I use the code below to creat takeofffiting between connector and pipe:

 

    foreach (var v in toConnects)
                {
                    ElementId tempTypeId = Util.GetPipeType(doc, v.ConType);//PipetypeId
                    ElementId zhiTypeId = v.Connector.Owner.GetTypeId();
                    Pipe ppp = v.Connector.Owner as Pipe;
                    v.Connector.Owner.ChangeTypeId(tempTypeId);
                    zhu.ChangeTypeId(tempTypeId);
                    FamilyInstance takeofff = doc.Create.NewTakeoffFitting(v.Connector, zhu);
                    sb_aaa.Append(takeofff.Id.ToString() + ",");
                    string s = takeofff.Symbol.Family.Name;
                    sb2.Append(takeofff.Id.ToString() + ":" + s+"\n");
                    doc.Regenerate();
            
                    ppp.ChangeTypeId(zhiTypeId);
                }

the variable "sb_aaa" is used to record the elementid I created.

The firist line of the  picture below is record of elementid I created; I use the "select by ID" command in Revit and paste the first line ,it shows me like the second picture. It seems tha all the element I created is deleted by Revit .

How can I avoid this?

 QQ截图20181001104227.pngQQ截图20181001103704.png

 

 

 

0 Likes
436 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

help me !

0 Likes
Message 3 of 3

FAIR59
Advisor
Advisor

As the instances get created, the fault should be in the next ( bit of ) code. So without extra information I can only make some (trivial) guesses.

  • have you committed the transaction ?
  • have you assimilated the transactiongroup ?
  • do you have an handled exception,  (try / catch code)  that contains the transaction?
  • if it's an ExternalCommand:  did you finish with Result.Succeeded ?
0 Likes