I’m working on automating the insertion of parts from a custom Plant 3D catalog into project drawings using a C# plugin.

What I have so far:

  • A custom catalog (.pspx, .acat, .pspc) with supports and other components.

  • I can retrieve the desired part from the catalog as a SpecPart using SpecManager and SpecPartReader.

The problem:

  • Methods like InsertCustomGeometryPlaceHolderInModel, InsertPlaceHolderInModel, and InsertPlaceHolderInModelWhileRouting require a block name.

  • The block name is only generated after the part is inserted, which creates a circular dependency:
    I need the block name to insert the part, but the block name only exists after insertion.

Goal:

  • Insert a part from the catalog into the Plant 3D drawing automatically, using the SpecPart (or PartSizeProperties) without requiring prior manual placement.

What I’ve Tried

Here’s an example of what I tried using InsertPlaceHolderInModel:

using Autodesk.ProcessPower.Piping;
using Autodesk.ProcessPower.Specification;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;

public void TryInsertPlaceholder()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;

    SpecManager specManager = SpecManager.GetSpecManager();
    SpecPart specPart = specManager.FindPart("MySpec", "PART_CODE");

    // Attempt to insert placeholder
    PnP3dPlaceholderUtil.InsertCustomGeometryPlaceHolderInModel(
        specPart.Name,
        "BLOCK_NAME", // <-- Problem: This name only exists after insertion
        specPart.PartType,
        familyID,  // Get it from specPart.PropNames
        specPart.NominalDiameter,
        "",        // Tag is usualy empty
        sizeProps,
        portProperties
    );

    doc.Editor.WriteMessage($"\nResult: {result.Status}");
}

Questions

  1. Is there a way to use the SpecPart I already have and finish the automated insertion into the project?
  2. If not, what are the recommended approaches for automated insertion from a catalog into Plant 3D drawings?
  3. Is PipingObjectAdder.Add(PartSizeProperties) the correct method for this? If yes, can someone provide a working example?

1 Reply 1

If you can't "insert", you need to find another method to "add"; then "move" or change the "Z-order" if that's the issue.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.