.NET

Reply
Distinguished Contributor
sanjaymann
Posts: 133
Registered: ‎05-22-2013
Message 1 of 10 (435 Views)
Accepted Solution

nwcout

435 Views, 9 Replies
10-06-2013 09:14 PM

Hi,

 

I know we can create navis file[.nwc] by using nwcout command but how do we create navis file [.nwc ] programatically.

 

Thanks & Regards

This needs to be done as follow:

 

[DllImport("accore.dll", CharSet = CharSet.Unicode,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "acedCommandS")]
private static extern int acedCommandS(
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);
acedCommandS(5005, "_NWCOUT", 5005, "c:\\Temp\\test.nwc", 5000);
Application.SetSystemVariable("FILEDIA", filedia);
}

 

ADN Support Specialist
philippe.leefsma
Posts: 662
Registered: ‎06-02-2009
Message 2 of 10 (395 Views)

Re: nwcout

10-08-2013 02:43 AM in reply to: sanjaymann

There is no API to export to .nwc format. You would need to programmatically send the nwcout command using Document.SendStringToExecute for example.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
sanjaymann
Posts: 133
Registered: ‎05-22-2013
Message 3 of 10 (390 Views)

Re: nwcout

10-08-2013 02:57 AM in reply to: philippe.leefsma

Ok. Got the point.I have used Document.SendStringToExecute with attsync :

Dim blname as String="Test"

 

Dim command As String = "_ATTSYNC Name " + blname + vbCr

           

doc.SendStringToExecute(command, True, False, False)

 

But I am unable to call NWCOUT I tried:

Dim path as String="c:\Test"

 

Dim command As String = "_NWCOUT Path " + path+ vbCr

           

doc.SendStringToExecute(command, True, False, False)

 

ADN Support Specialist
philippe.leefsma
Posts: 662
Registered: ‎06-02-2009
Message 4 of 10 (388 Views)

Re: nwcout

10-08-2013 03:05 AM in reply to: sanjaymann

Which version of AutoCAD are you using? Because in plain AutoCAD I can't see a NWCOUT command...



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
sanjaymann
Posts: 133
Registered: ‎05-22-2013
Message 5 of 10 (381 Views)

Re: nwcout

10-08-2013 03:15 AM in reply to: philippe.leefsma

Autocad 2013

Distinguished Contributor
sanjaymann
Posts: 133
Registered: ‎05-22-2013
Message 6 of 10 (378 Views)

Re: nwcout

10-08-2013 03:24 AM in reply to: philippe.leefsma

The following code prompts me for the path:

Dim dbt AsDatabase = Application.DocumentManager.MdiActiveDocument.Database

           

Dim doc2 AsDocument = Application.DocumentManager.MdiActiveDocument

           

Dim command AsString = "_NWCOUT " + "d:\w.nwc" + vbCr

 doc2.SendStringToExecute(command,True, False, False)

 

How do I manage to pass the file path to the command

ADN Support Specialist
philippe.leefsma
Posts: 662
Registered: ‎06-02-2009
Message 7 of 10 (372 Views)

Re: nwcout

10-08-2013 04:10 AM in reply to: sanjaymann

This needs to be done as follow:

 

[DllImport("accore.dll", CharSet = CharSet.Unicode,
    CallingConvention = CallingConvention.Cdecl,
    EntryPoint = "acedCommandS")]
private static extern int acedCommandS(
    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);

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

    Application.SetSystemVariable("FILEDIA", filedia);

}

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
sanjaymann
Posts: 133
Registered: ‎05-22-2013
Message 8 of 10 (334 Views)

Re: nwcout

10-09-2013 01:22 AM in reply to: philippe.leefsma

Thanks. This worked like a charm:smileyhappy:

New Member
cornking84
Posts: 1
Registered: ‎03-06-2014
Message 9 of 10 (92 Views)

Re: nwcout

09-23-2014 06:53 PM in reply to: philippe.leefsma

Hi, Philippe. It was really helpful.

 

It works fine with AutoCAD 2015, but I need to use this command for AutoCAD 2011.

 

How can I change values for AutoCAD 2011?

ADN Support Specialist
philippe.leefsma
Posts: 662
Registered: ‎06-02-2009
Message 10 of 10 (85 Views)

Re: nwcout

09-24-2014 12:57 AM in reply to: cornking84

For 2011 use acedCommand instead and it is exported directly by acad.exe I believe.

 

Try the following:

 

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

 

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.