Dear Ning and Jon,
Thank you for your update. Yes, something has has indeed happened in the meantime.
Ning, you mention the old SPR #217278 [Wishlist: Ability to set the piping system type via the API if the pipe was created via the API].
Please always keep track of the numbers of these issues, since they provide our main key for tracking them. The descriptions are editable and sometimes change.
I have dealt with two other ADN cases related to this topic, 08281195 [MEP pipes and placeholders assign system type] and 09691948 [Unable to change a duct's System Type in an Add-in].
The old SPR has been migrated to a new system and evolved into REVIT-28762 [API bug calling Pipe.Create].
I am telling you this mainly for my own sake, to simplify future tracking purposes.
Interestingly enough, the latter has been closed and marked as 'Works As Expected'.
Here is the case history of this issue:
[Q] I am unable to determine a valid argument to pass in as a piping system type to Pipe.Create. Is it possible at all? Sample code and further discussion is provided by The Building Coder:
http://thebuildingcoder.typepad.com/blog/2014/01/creating-a-rolling-offset-pipe-between-two-pipes.ht...
[A] I looked at the code in "The Building Code" about Pipe.Create.
In 2014, we provided the new static Pipe.Create method to create the pipe taking six arguments:
- document: The document.
- systemTypeId: The id of the piping system type.
- pipeTypeId: The id of the pipe type.
- levelId: The level id for the pipe.
- firstPoint: The first point of the pipe.
- secondPoint: The second point of the pipe.
The systemTypeId is to let user choose which system type the new create pipe belongs to, such as 'Hydronic Supply'/Sanitary etc.
The old document.NewPipe has no systemTypeId parameter, so the new created pipe will use the default system type (Hydronic Supply).
In the page, you called: ElementId idSystem = pipe.MEPSystem.Id;
This is not system type id, but system id.
You should call : ElementId systemTypeId = pipe.MEPSystem.GetTypeId();
In 2015, we provided another 2 Pipe.Create static functions.
create( Document, ElementId pipeTypeId, ElementId levelId, Connector startConnector, XYZ endPoint );
Note: if you want the start point connect to one existing element, just need to pass the connector of the existing element as 'startConnector'.
create( Document, ElementId pipeTypeId, ElementId levelId, Connector startConnector, Connector endConnector );
Note: If you want the newly created pipe to connect to two existing elements, you can pass two connectors of the exisitng elements as 'startConnector' and 'endConnector'.
In your article 'Creating a Rolling Offset Pipe Between Two Pipes', I would suggest you to use the third pipe.Create.
BTW: the two new Revit 2015 pipe.Create overloads take no systemTypeId, because the newly created pipe will have same system type as the connected elements.
You also can create your own system types. E.g., for a pipe, you ccould do so by calling PipingSystemType.Create.
From this, you can determine the system type id from the new created system system type element.
Does this solve your problem?
As far as I can tell, it looks like the new Pipe.Create function can solve your problem.
Could you please have a try and let us know if you have any further question on this?
Thank you!
I hope this helps.
Best regards,
Jeremy