Home Forums Development Create CAD Document using IOM API

This topic contains 2 replies, has 2 voices, and was last updated by  Kovair 1 week, 1 day ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10454

    Kovair
    Participant

    Hi,

    How can I create and attach file with a  CAD Document through IOM API?

    Here is the code I am trying to implement.

    <hr />

    // Create the CAd Document item

    var docItem = MyInnovator.newItem(“CAD”, “add”);
    docItem.setProperty(“item_number”, “CADDoc 004”);

    // Create the File item and set the path to the file.
    var fileItem = MyInnovator.newItem(“File”, “add”);
    fileItem.setProperty(“filename”, “My Document.docx”);
    fileItem.attachPhysicalFile(“D:\\My Document.docx”);

    // Create the relationship between the CAd Document and File
    var relItem = MyInnovator.newItem(“CADFiles”, “add”);
    docItem.addRelationship(relItem);

    relItem.setRelatedItem(fileItem);
    var results = docItem.apply();

    <hr />

    I guess CAD files are null able type of relation since there is null value in related id column in CADFiles table…

     

    #10457

    Hello,

    It appears that the CADFiles relationship is unique in that it is not a relationship between the CAD and File itemtypes. Rather, it is a null relationship with a file property called “attached_file”.

    I have updated the sample Method you provided to account for this. Additionally, I have updated your sample to use the newer setFileProperty function that is in 11.0 SP9.

    // Create the CAd Document item
    
    var docItem = MyInnovator.newItem("CAD", "add");
    docItem.setProperty("item_number", "CADDoc 004");
    
    // Create the relationship between the CAd Document and File
    var relItem = MyInnovator.newItem("CADFiles", "add");
    relItem.setFileProperty("attached_file", @"C:\Temp\Test.txt");
    
    docItem.addRelationship(relItem);
    
    var results = docItem.apply();

    If you are using a version of Innovator before 11.0 SP9, you will need to rewrite this sample to use the attachPhysicalFile function that you were using initially.

    Chris

    ______________________________________

    Christopher Gillis

    Aras Labs Software Engineer

     

    #10477

    Kovair
    Participant

    Thank you Chris, I think it should work.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.