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: 

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

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
360 Views, 2 Replies

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

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

 

 

 

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

help me !

Message 3 of 3
FAIR59
in reply to: Anonymous

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 ?

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

Post to forums  

Rail Community


Autodesk Design & Make Report