Message 1 of 2
Can't Convert from MEP Design elements to FabricationPart with DesignToFabricationConverter class
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I'm new with Fabrication Parts in Revit API, I want to convert MEP Design elements ( ducts and pipes ) to fabrication Part given a service, but at themoment of execute the transaction , convertResult is Success but not make any change in MEP Elements, the mep elements still the same as before, this piece of code is the transaction, designIdSet is a HashSet<ElementId>.
public void CreateFabricationPartFromService(Element element, List<Connector> unusedConnectors, int serviceId)
{
using (var transaction = new Transaction(_document, "CreateAndCoupleFabPart"))
{
transaction.Start();
var elementLevel = element.LevelId;
var designIdSet = MEPHelper.CreateMEPElementsFromConnectors(unusedConnectors, _document, 3, elementLevel);
var convertResult = _designToFabrication.Convert(designIdSet, serviceId);
var FabSets = _designToFabrication.GetConvertedFabricationParts();
_document.Regenerate();
_uiDocument.RefreshActiveView();
transaction.Commit();
}
}
i don't know if is because of the way that the CreateMEPElementsFromConnectors method created these parts, for the moment im only make test creating pipes, i don't know if i'm doing something wrong at the moment of creating MEP elements:
public static HashSet<ElementId> CreateMEPElementsFromConnectors(List<Connector> connectors, Document document, float length, ElementId levelId)
{
PipeType pipeType = new FilteredElementCollector(document)
.OfClass(typeof(PipeType))
.Cast<PipeType>()
.FirstOrDefault();
FilteredElementCollector pipingSystemTypes = new FilteredElementCollector(document)
.OfClass(typeof(PipingSystemType));
var systemTypeId = pipingSystemTypes.FirstElementId();
var resultSet = new HashSet<ElementId>();
foreach (var connector in connectors)
{
if (connector.Domain == Domain.DomainPiping)
{
var startPoint = connector.Origin;
var direction = connector.CoordinateSystem.BasisZ;
var endPoint = startPoint + direction * length;
var start2point = startPoint + direction * length / 2;
var pipe = Pipe.Create(document,systemTypeId,pipeType.Id,levelId,start2point,endPoint);
resultSet.Add(pipe.Id);
}
else if (connector.Domain == Domain.DomainHvac)
{
DuctType ductType = new FilteredElementCollector(document)
.OfClass(typeof(DuctType))
.Cast<DuctType>()
.FirstOrDefault(x => x.Shape == connector.Shape);
var startPoint = connector.Origin;
var direction = connector.CoordinateSystem.BasisZ;
var endPoint = startPoint + direction * length;
var duct = Duct.Create(document, ductType.Id, levelId, connector, endPoint);
resultSet.Add(duct.Id);
}
}
return resultSet;
}
Thanks.
Developer Advocacy and Support +