Author Topic: Output .ITM File using SaveItem() or SaveItemAs()  (Read 121 times)

0 Members and 1 Guest are viewing this topic.

Offline jaysomlamTopic starter

  • Full Member
  • ***
  • Posts: 144
  • Country: us
  • Gender: Male
Output .ITM File using SaveItem() or SaveItemAs()
« on: Dec 07, 2018, 08:06:24 PM »
Has anyone tried using ContentManager.SaveItemAs() or ContentManager.SaveItem() to output an .ITM file for a duct item? Somehow they both fail when I try. I am wondering what I have done wrong and how I can output .ITM files from a group of duct?

The following is a program that I try using SaveItemAs() to output .ITM file for each duct in the drawing:

Code: [Select]
.
.
using Autodesk.Fabrication.Content;     // For using ContentManager.
using Autodesk.Fabrication.Results;     // For using ResultStatus.
.
.
[CommandMethod("MyLib_SaveAllToItmFiles")]
public void SaveAllToItmFiles()
   // Save all the duct on the drawing into their .ITM files.
   {
   Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
   Editor   ed  = doc.Editor;

   foreach( Item itm in Job.Items )
      {
      String sItemFileNoExt = "MyTest - " + itm.Name.Trim();
      if ( ContentManager.SaveItemAs( itm, "C:\\Temp", sItemFileNoExt, true ).Status == ResultStatus.Failed )
         {
         ed.WriteMessage( "\nFail to save a duct to its .ITM file" );
         }
      }
   }

Yes, the C:\Temp exists and my user account can save file into that folder.  But the program keeps telling me that it cannot save the duct to their .ITM files.  And I don't see any .ITM file generated.  I don't know what I can do to make it work.  Would you please help me with this?  By the way, I am using CADmep 2018 with a valid license.

Jaysom

Offline DotNet

  • Full Member
  • ***
  • Posts: 55
  • Country: us
  • Gender: Male
Re: Output .ITM File using SaveItem() or SaveItemAs()
« Reply #1 on: Dec 07, 2018, 09:09:31 PM »
The ContentManager Class is for ItemType DiskItem. You're working with ItemType JobItem. If you really want to do this, you can create a DiskItem, then copy the relevant JobItem information to it.

Code: [Select]

var DiskItem = ContentManager.CreateItem(JobItem.CID);


« Last Edit: Dec 07, 2018, 09:19:04 PM by DotNet »

Offline jaysomlamTopic starter

  • Full Member
  • ***
  • Posts: 144
  • Country: us
  • Gender: Male
Re: Output .ITM File using SaveItem() or SaveItemAs()
« Reply #2 on: Dec 10, 2018, 02:43:25 PM »
I am very surprised to see that there is no direct way to save a job-item into a disk-item.  Seem like the properties of a disk item will need to be setup individually based on the piece-type after using the ContentManager.CreateItem() command.

I am wondering if this is intentional to discourage people from doing this.  May be the info of job-items generated into disk-items is in an one-way street and will not be linked back to the original job-items?  May be the Tracker will not be able to track a disk-item back to its original job-item and cannot update the status of the job-item?  If this is the case, then this is not something that I should pursue, and I will need to look for a different way to send job items to CAMduct automatically.

Jaysom

Offline jaysomlamTopic starter

  • Full Member
  • ***
  • Posts: 144
  • Country: us
  • Gender: Male
Re: Output .ITM File using SaveItem() or SaveItemAs()
« Reply #3 on: Dec 11, 2018, 12:54:30 PM »
Based on the explanation that I received in my post "Job Items vs Disk Items" in CAMduct Users forum, I realized that Disk Items are pattern with default values.  They are not in place of Job Items.  And Disk Items are good for importing duct from duct system of a different vendor.  For my purpose of transferring duct from CADmep to CAMduct, I should stick with Job Items and should not use Disk Items.  Therefore, I will not pursue on this issue any further.

For people who still want to know how to use SaveItem() or SaveItemAs() to generate .ITM files for Disk Items, FabricationSample has some examples.

I consider this issue as solved.

Jaysom