Update category of copied schedule/quantity

Update category of copied schedule/quantity

Anonymous
Not applicable
606 Views
4 Replies
Message 1 of 5

Update category of copied schedule/quantity

Anonymous
Not applicable

Hey,

 

I am using the following code to copy a schedules/quantities element from on document to another.

 

private static ICollection<ElementId> DuplicateSchedules(Document from, IEnumerable<ViewSchedule> schedules, Document to)
{
    var ids = schedules.AsEnumerable<View>().ToList<View>().ConvertAll<ElementId>(v => v.Id);

    return DuplicateElementsAccrossDocuments(from, ids, to);
}

private static ICollection<ElementId> DuplicateElementsAccrossDocuments(Document from, ICollection<ElementId> ids, Document to)
{
    ICollection<ElementId> copies = null;
    using (var transaction = new Transaction(to, "Duplicate Elements"))
    {
        if (transaction.Start() == TransactionStatus.Started)
        {
            // Use destination types if duplicates found
            var options = new CopyPasteOptions();
            options.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler());

            copies = ElementTransformUtils.CopyElements(from, ids, to, Transform.Identity, options);

            // Delete cannot copy duplicates warning
            var failureOptions = transaction.GetFailureHandlingOptions();
            failureOptions.SetFailuresPreprocessor(new HidePasteDuplicationTypesPreprocessor());

            transaction.Commit();
        }
    }
    return copies;
}

It works, but the copied schedule is placed under a ??? category.

 

project-browser.png

 

The category can be changed manually by editing Projectbrowser -> Constraints.

 

properies.png

 

Sadly I wasn't able to find a way to do this in the API. Is that even possible?

0 Likes
Accepted solutions (1)
607 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

bump

0 Likes
Message 3 of 5

PavelAnd
Advisor
Advisor

Hello @Anonymous. Is this a text parameter? How about creating a new transaction after adding specifications and filling out their parameter with the code below?

 

foreach (ElementId copy in copies)
{
    doc.GetElement(copy).LookupParameter("Projektbrowser Gliederung 1").Set("ALLGEMEIN");
}

 

Best regards, Pavel Plotitsyn.

0 Likes
Message 4 of 5

Anonymous
Not applicable

This works, thanks. Do you know if it's possible to create a new node like "ALLGEMEIN"?

0 Likes
Message 5 of 5

PavelAnd
Advisor
Advisor
Accepted solution

You can write any name, which you want and it will add node to your project browser.

Best regards, Pavel Plotitsyn.

0 Likes