Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automatically save .nwc file with the same name as the .dwg/no dialog box

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
tq1918
1170 Views, 2 Replies

Automatically save .nwc file with the same name as the .dwg/no dialog box

^C^C_Mfiledia^M0^M_nwcout^M^M_filedia^M1

 

I am using this macro/command to Automatically cancel any active commands, change dialog pop-up box to OFF, create a NWcache file, save the nwc file with the same name as the dwg name, change the dialog pop-up box to ON. (end of command)

 

Problem:  Sometimes the exporter places the nwc file in the last place I pulled an Xref from, instead of the same file location as the dwg.  Sometimes it works perfectly. 

 

Any ideas how to make the .nwc save without dialog box. 

 

Saving elsewhere or renaming the file on the fly is not important for me.

 

And before I get smart aleck responses.

I know that enter enter is a simple solution with the dialog box on. However this is very short part of a very long Macro string.  The part of the string that has the problem is listed above.  

2 REPLIES 2
Message 2 of 3
tq1918
in reply to: tq1918

Update

 

_filedia^M0^M_nwcout^M^M_filedia^M1

 

I copied the macro wrong, before it had an extra ^M in it (macro was in the middle of a longer string)

 

I have noticed that opening dwgs from the windows explorer is part of the problem.  If I open the dwg from AutoCAD Dialog box it helps, as long as I don’t exref anything into my dwg.  I cannot work on two dwgs at the same time in different locations.  All nwcs will be place in the file location of the first file opened in AutoCAD or the location of the last exref pulled into my dwg.  Any thoughts on how to modify this?

 

HELP!  My short cut is turning into a hindrance.  

 

Should I add this to wishlist for 2016?

Message 3 of 3
Balaji_Ram
in reply to: tq1918

Hi,

 

Sorry for the delay.

 

I do not see a way to get this working only using macros.

Will creating a custom command using AutoCAD .Net API to export be an option for you ?

The .Net plugin can be configured for loading at startup and the custom command can be used from inside your macro just as any other AutoCAD command. That should help save the file at any path of your choice.

 

Here is a sample code that my colleague Philippe Leefsma had recently implemented. It invokes the NWCOUT using AutoCAD .Net API.

 

[DllImport("accore.dll", 
    CharSet = CharSet.Unicode, 
    CallingConvention = CallingConvention.Cdecl, 
    EntryPoint = "acedCmd")]
public static extern int acedCmd(System.IntPtr vlist);
 
[CommandMethod("acedCmdTest")]
static public void acedCmdTest()
{
    ResultBuffer rb = new ResultBuffer();
           
    rb.Add(new TypedValue(5005, "ZOOM"));
    rb.Add(new TypedValue(5005, "E"));
            
    acedCmd(rb.UnmanagedObject);
}

[DllImport("accore.dll", CharSet = CharSet.Unicode,
    CallingConvention = CallingConvention.Cdecl,
    EntryPoint = "acedCommand")]
private static extern int acedCommand(
    int type1,
    string str1,
    int type2,
    string str2,
    int end);

[CommandMethod("NwcOutNet")]
public void NwcOutNet()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;

    object filedia = Application.GetSystemVariable("FILEDIA");
    Application.SetSystemVariable("FILEDIA", 0);

    acedCommand(5005, "_NWCOUT", 5005, "c:\\Temp\\test.nwc", 5000);

    Application.SetSystemVariable("FILEDIA", filedia);
}

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report

”Boost