Author Topic: Loaditem  (Read 798 times)

0 Members and 1 Guest are viewing this topic.

Offline Andy0777Topic starter

  • Active Member
  • **
  • Posts: 48
  • Country: gb
  • Gender: Male
    • Ductwork site books and software training
Loaditem
« on: May 18, 2024, 12:03:26 PM »
Good morning CAMduct API programmers.

I am trying to create an addin for CAMduct that uses the ContentManager.LoadItem Method.

Can anyone provide me with a line of code or two just to get one bit of straight rectangular duct into a job?

I have gone to the SDK and tried using the examples but I think I'm missing something.

Any help is greatly appreciated.  :)

Code snippet below: (FabricationAPI.dll has been loaded to references)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Fabrication;
using System.Xml.Linq;
using Autodesk.Fabrication.Content;

namespace Itemload
{
    public class Class1
    { /// <summary>
 /// Loads an Item from disk and updates properties.
 // </summary>
 /// <param name="path">The path to the item on disk, including the item name i.e. path/item.itm</param>
 /// <param name="alias">The alias property to update on the loaded item</param>
 /// <param name="orderNumber">The order property to update on the loaded item</param>
 /// <param name="notes">The notes property to update on the loaded item</param>
 /// <returns>True if the item was loaded and updated, false if not.</returns>
 public static bool LoadItemAndUpdateProperties(string path, string alias, string orderNumber, string notes)
        {
            bool updated = false;
            using (var itm = ContentManager.LoadItem("C:\\Users\\Public\\Documents\\Autodesk\\Fabrication 2020\\Metric Content\\V7.06\\Items\\HVAC\\Generic\\Rectangular\\Straight(Coil).ITM"))
            {
                if (itm != null)
                {
                    itm.Alias = alias;
                    itm.Order = orderNumber;
                    itm.Notes = notes;
                    if (ContentManager.SaveItem(itm).Status == ResultStatus.Succeeded)
        updated = true;
    }
  }

  return updated;
}
    }
}
Ductwork manufacture
CAMduct, CADmep, Revit

Offline Darren Young

  • Premier Member
  • *****
  • Posts: 2112
  • Country: us
  • Gender: Male
    • BIM There Done That.
Re: Loaditem
« Reply #1 on: May 21, 2024, 17:09:12 PM »
I think you're using the wrong Method. That loads the details of an item into memory....similar to LOAD.ITEM() in a COD Script.

I think what you're looking for is...

Job.AddItem (Autodesk.Fabrication Namespace)

Offline Andy0777Topic starter

  • Active Member
  • **
  • Posts: 48
  • Country: gb
  • Gender: Male
    • Ductwork site books and software training
Re: Loaditem
« Reply #2 on: May 21, 2024, 17:59:48 PM »
Thanks Darren

Much appreciated as always.

I'll let you know how I get on.

Kind Regards

Andy
Ductwork manufacture
CAMduct, CADmep, Revit

Offline Darren Young

  • Premier Member
  • *****
  • Posts: 2112
  • Country: us
  • Gender: Male
    • BIM There Done That.
Re: Loaditem
« Reply #3 on: May 23, 2024, 19:33:14 PM »
Can I assume from your recent LinkedIn post you got along ok?  ;)