astian
astian

Reputation: 684

Not able to Convert .dwg to .pdf using .Net and True View (AcCtrl)

What I am trying to do is:

I have a Asp Mvc website. In it I need to create a function that does the following:

I started with the, what I tought at the time, easier task to have the .dwg to a .pdf. After some research I found out that a way to do that (without buying a 3rd party license) is to install TrueView on the server and using it (or actually a AcCtrl.dll) to convert the file. Well, I did so. I installed the True View program and added a reference to AcCtrl Component (ACCTRLLib). Then I added a reference to the Dll inside the class file I am working on:

using ACCTRLLib;

So far so good. After that I followed the instructions on this post: PDF conversion using dwg true viewer in VB6

First, this is my code:

public static void ConvertFile()
{    
    IAcCtrl contrl = new AcCtrl();
    contrl.PutSourcePath(@"D:\MMA\Autocat\File1.dwg");
    string[] pdfPath = new string[1] { @"D:\MMA\Autocat\File1.dwg" };
    contrl.SilentPublish(pdfPath);
}

Then, according to the post, I went to see if there is a registry with the specified path. The path that I have as a registry is the following:

HKEY_CURRENT_USER\Software\Autodesk\DWG TrueView\R13\DWGVIEWR-E001:409\Profiles\<<\Unnamed Profile>>\Dialogs\AcPublishDlg

So, I created a 'String Value' in it with ValueName: Location and ValueData: D:\MMA\Autocat\Testing

Alright. So, thats it. After all that I ran the application and called the function. The debugger goes through the code and everything executes (or at least looks like so) but nothing happens. I don't get a file in the D:\MMA\Autocat\Testing folder. I get no exception, no warning nothing. It just executes and nothing happens.

So what else did I tried. Some of those things might be a little naive or silly to try but nevertheless I did as I happen to be a little desperate.

  1. I tried everything in a console application. I wasnt completely sure that this method is suitable for ASP MVC so I tried the same code with a console application unfortunatelly to the same result.

  2. I added a file name inside the location string value. I changed the Location ValueData from 'D:\MMA\Autocat\Testing' to 'D:\MMA\Autocat\Testing\testFile.pdf' as I noticed that nowhere in the whole process a file name is asked for the converted file.

  3. Following my thought from the previous conclusion I tried to supply the path to the 'result' file to the SilentPublish function.

    string[] pdfPath = new string[1] { @"D:\MMA\Autocat\Testing\testFile.pdf" }; contrl.SilentPublish(pdfPath);

Again to no avail. So, my question, or rather questions are:

Is it possible to do it this way and if it is what am I doing wrong? If its not than can you suggest a way? Also if a .dwg to .dwf conversion is possible (with the same or different method I am all ears)

Thank you very much

Upvotes: 2

Views: 2361

Answers (2)

Julie Garcia
Julie Garcia

Reputation: 1

I'm not sure if you are still having this issue, but you should be able to do this with the Autodesk Forge API. Calls can be made from any language with a simple HTTP call. You will have to first convert to SVF and then to DXF and PDF from there.

Upvotes: 0

Miiir
Miiir

Reputation: 831

True View does not expose the Autodesk.AutoCAD.PlottingServices namespace. You're going to need either a licensed copy of AutoCAD, RealDWG, or another third party API.

Upvotes: 2

Related Questions