.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

eTransmit does not bind xRefs

9 REPLIES 9
Reply
Message 1 of 10
阿黄狗
390 Views, 9 Replies

eTransmit does not bind xRefs

With the following code, can not bind xrefs,I don't know why?

[CommandMethod("TESTETRANSMIT2022")]
public static void ETransmitDwg2022()
{
    TransmittalOperation tro = new TransmittalOperation();
    TransmittalInfo ti = tro.getTransmittalInfoInterface();
    ti.BindType = BindType.eBind;
    ti.depathXrefs = 1;
    ti.destinationRoot = "D:\\TransmittalSet\\";
    ti.saveVersion = SaveDwgFormat.eNoConversion;
    ti.visualFidelity = 1;

    ti.purgeDatabase = 1;
    ti.resetPlotter = 1;

    ti.includeDataLinkFile = 0;
    ti.includeDGNUnderlay = 0;
    ti.includeDWFUnderlay = 0;
    ti.includeFontFile = 0;
    ti.includeImageFile = 0;
    ti.includeMaterialTextureFile = 0;
    ti.includeNestedOverlayXrefDwg = 0;
    ti.includePDFUnderlay = 1;
    ti.includePhotometricWebFile = 0;
    ti.includePlotFile = 0;
    ti.includeUnloadedReferences = 0;
    ti.includeUnloadedXrefDwg = 0;
    ti.includeXrefDwg = 0;

    TransmittalFile tf = null;
    string dwgFile = @"D:\新建文件夹\Drawing2.dwg";
    AddFileReturnVal val = tro.addDrawingFile(dwgFile, out tf);
    tro.createTransmittalPackage();
}

56F00DDE-3A94-412a-889D-79B8373A0922.png

9 REPLIES 9
Message 2 of 10
ehsan_bahrani
in reply to: 阿黄狗

hi

according to IncludeXrefDwg Property (ActiveX/ATO) Autocad Documents maybe you need to change this line:

 

 

    ti.includeXrefDwg = 0;

 

 

to

 

 

    ti.includeXrefDwg = 1;

 

 

 

 

 

 
 
 
 
 
Message 3 of 10
阿黄狗
in reply to: ehsan_bahrani

change the line " ti.includeXrefDwg = 1;"  also  didn't work ; 9C37B574-F184-4b34-A3C8-D7B78E7E9C6A.png

Message 4 of 10
ehsan_bahrani
in reply to: 阿黄狗

sorry maybe i misunderstand what you want to do.

binding a xRef is complitly different from eTransmit, in other word you have to do this tasks seperately, maybe you need first bind xRef and after that try to eTransmit.

for binding you can use this documentation.

Message 5 of 10
daniel_cadext
in reply to: 阿黄狗

you can use TransmittalAddFileNotificationHandler, or another Transmittal event  to preprocess  stuff.

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 6 of 10
阿黄狗
in reply to: daniel_cadext

I try it like this,but also not work; the database can not change;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AcETransmit;
using AutoCAD;
using Autodesk.AutoCAD.Runtime;

namespace ETransmitDwg2022
{
    internal class MyTransFileNotifier : TransmittalAddFileNotificationHandler
    {
        public void addFileNotificationHandler(TransmittalFile pFile, TransmittalOperation pTransmit)
        {
            if (pFile.database != null)
            {
                AcadDatabase acDb = pFile.database;
                if (acDb != null)
                {
                    foreach (AcadBlock block in acDb.Blocks)
                    {
                        if (block.IsXRef)
                        {
                            block.Bind(true);
                        }
                    }
                }        
            }
        }

        public void beginFilesGraphCreation(TransmittalOperation pTransmit) { }
        public void endFilesGraphCreation(TransmittalOperation pTransmit) { }
    }


    internal class datahandle : TransmittalDatabaseNotificationHandler
    {
        public int preDatabaseProcessing(object pDatabase, TransmittalFile pFile, TransmittalOperation pTransmit)
        {
            if (pDatabase != null)
            {
                AcadDatabase acDb = (AcadDatabase)pDatabase;
                if (acDb != null)
                {
                    foreach (AcadBlock block in acDb.Blocks)
                    {
                        if (block.IsXRef)
                        {
                            block.Bind(true);
                        }
                    }
                }
            }
            return 1;
        }

        public int postDatabaseProcessing(object pDatabase, TransmittalFile pFile, TransmittalOperation pTransmit)
        {
            if (pDatabase != null)
            {
                AcadDatabase acDb = (AcadDatabase)pDatabase;
                if (acDb != null)
                {
                    foreach (AcadBlock block in acDb.Blocks)
                    {
                        if (block.IsXRef)
                        {
                            block.Bind(true);
                        }
                    }
                }
            }
            return 1;
        }

        public int convertDatabase(object pDatabase, TransmittalFile pFile, TransmittalOperation pTransmit)
        {
            if (pDatabase != null)
            {
                AcadDatabase acDb = (AcadDatabase)pDatabase;
                if (acDb != null)
                {
                    foreach (AcadBlock block in acDb.Blocks)
                    {
                        if (block.IsXRef)
                        {
                            block.Bind(true);
                        }
                    }
                }
            }
            return 1;
        }
    }

    public class Class1
    {
        private static MyTransFileNotifier myTransFileNotifier = new MyTransFileNotifier();
        private static datahandle datah = new datahandle();

        [CommandMethod("TESTETRANSMIT2022")]
        public static void ETransmitDwg2022()
        {
            TransmittalOperation tro = new TransmittalOperation();

            tro.subscribeToAddFileNotification(myTransFileNotifier);
            tro.subscribeDatabaseNotification(datah);

            TransmittalInfo ti = tro.getTransmittalInfoInterface();
            ti.BindType = BindType.eBind;
            ti.depathXrefs = 1;
            ti.destinationRoot = "D:\\TransmittalSet\\";
            ti.saveVersion = SaveDwgFormat.eNoConversion;
            ti.visualFidelity = 1;

            ti.purgeDatabase = 1;
            ti.resetPlotter = 1;

            ti.includeDataLinkFile = 0;
            ti.includeDGNUnderlay = 0;
            ti.includeDWFUnderlay = 0;
            ti.includeFontFile = 0;
            ti.includeImageFile = 0;
            ti.includeMaterialTextureFile = 0;
            ti.includeNestedOverlayXrefDwg = 0;
            ti.includePDFUnderlay = 1;
            ti.includePhotometricWebFile = 0;
            ti.includePlotFile = 0;
            ti.includeUnloadedReferences = 0;
            ti.includeUnloadedXrefDwg = 0;
            ti.includeXrefDwg = 1;

            TransmittalFile tf = null;
            string dwgFile = @"D:\00\Drawing2.dwg";
            AddFileReturnVal val = tro.addDrawingFile(dwgFile, out tf);
            tro.createTransmittalPackage();
        }
    }
}
Message 7 of 10
阿黄狗
in reply to: ehsan_bahrani

Thank you for your answer, I just want to replicate that function in the picture;I wonder how autocad is implemented , use eTransmit and Bind Dwg Files94776762-FB10-468a-B935-C5FD9D88E60A.png

Message 8 of 10
daniel_cadext
in reply to: 阿黄狗

 

Well, that’s a bummer, wondering if you need to save the drawing so etransmit sees the changes

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 9 of 10
阿黄狗
in reply to: daniel_cadext

but the NotificationHandler can only get database, the AcadDatabase can not save, only AcadDocument can save; so use database(AcadDatabase ) can not save the drawing;1313AF37-025B-42cb-B319-D92F29278F55.pngE4BDA31B-91D3-4bb2-A2B3-5C869AD94987.png

Message 10 of 10
daniel_cadext
in reply to: 阿黄狗

So, somehow you need to get the .NET version of the database, which does have a saveas method.

ARX has a global function acdbActiveDatabaseArray, I don’t know if there’s a .NET equivalent.

Or maybe there’s a way to get a .net instance of the database from COM

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report