Code Red > .NET

acedCmd with Civil 3D 2017

(1/2) > >>

latour_g:
Hi,

I have this in my coding for Civil 3D 2014 and it's working fine :


--- Code - C#: ---[DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl)]extern static int acedCmd(IntPtr resbuf);
With Civil 3D 2017 it's doesn't work, it says acedCmd is not found in accore.dll

I'm using VS 2010, .NET Framework 4.0 for Civil 3D 2014 and VS 2012, .NET Framework 4.5 for Civil 3D 2017. 

Jeff_M:
Reference the ObjectARX 2017 libraries.

gile:
Hi,

Since A2015, you have to use the managed Editor.Command (or Editor.CommandAsync()) method.

You can see this topic and this one.

Jeff_M:
gile, I know that the acedCmd was supposed to be removed, but we still have code using it which works fine in 2015-2018 versions.

latour_g:
Thanks for your reply.

Jeff_M : I have change for ObjectARX 2017 but it still doesn't work.  No error message but it just do nothing. 

gile : I have tried them both but I got an error message :

L'application ne prend pas en charge le débogage
juste-à-temps (JIT). Consultez la fin de ce message pour plus de détails.

************** Texte de l'exception **************
System.ArgumentException: La valeur n'est pas comprise dans la plage attendue.
   à Autodesk.AutoCAD.DatabaseServices.ResultBuffer.ObjectToResbuf(Object o, resbuf** rb)
   à Autodesk.AutoCAD.Runtime.Marshaler.ObjectToResbuf(Object o)
   à Autodesk.AutoCAD.Runtime.Marshaler.ObjectsToResbuf(Object[] objects)
   à Autodesk.AutoCAD.EditorInput.Editor.Command(Object[] parameter)
   à C3DSectionPlot.SectDlg.acPlotSection() dans c:\prog\STN_R_C3DSectionPlot_2017\SectDlg.cs:ligne 1674
   à C3DSectionPlot.SectDlg.btnPrint_Click(Object sender, EventArgs e) dans c:\prog\STN_R_C3DSectionPlot_2017\SectDlg.cs:ligne 1455
   à System.Windows.Forms.Control.OnClick(EventArgs e)
   à System.Windows.Forms.Button.OnClick(EventArgs e)
   à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   à System.Windows.Forms.Control.WndProc(Message& m)
   à System.Windows.Forms.ButtonBase.WndProc(Message& m)
   à System.Windows.Forms.Button.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

You won’t be able to test this code but here it is, to give you an idea of what I’m doing :


--- Code - C#: ---        private void acPlotSection()        {            Document doc = AcadApp.DocumentManager.MdiActiveDocument;              using (ResultBuffer buffer = new ResultBuffer())            {                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "_-Plot"));                // 1- detail plot configuration                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, UTIL.showRscText(rm.GetString("acYES"))));                // 2- layout name                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, LayoutManager.Current.CurrentLayout));                // 3- device name                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, this.cboPrinter.SelectedItem.ToString()));                // 4- paper size                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, this.cboMedia.SelectedItem.ToString()));                // 5- paper units                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, ((pltSet.PlotPaperUnits == PlotPaperUnit.Millimeters) ? "M" : UTIL.showRscText(rm.GetString("acInches")))));                // 6- drawing orientation                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, (this.rbLandscape.Checked) ? UTIL.showRscText(rm.GetString("acLandscape")) : "P"));                // 7- symetrie verticale                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                // 8- plot area                if (this.cboArea.SelectedIndex == 1)                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, UTIL.showRscText(rm.GetString("acWindow"))));                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTPOINT, pltWindow.MinPoint));                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTPOINT, pltWindow.MaxPoint));                }                else if (this.cboArea.SelectedIndex == 2)                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, UTIL.showRscText(rm.GetString("acLayout"))));                }                else                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "E"));                }                // plot scale                if (this.chkFit.Checked)                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, UTIL.showRscText(rm.GetString("acFit"))));                }                else                {                    if (pltSet.UseStandardScale == true)                    {                        buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTREAL, pltSet.StdScale));                    }                    else                    {                        CustomScale scale = pltSet.CustomPrintScale;                        buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTREAL, scale.Numerator / scale.Denominator));                    }                }                // plot offset                if (this.cboArea.SelectedIndex == 2)                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTPOINT, new Point2d(0, 0)));                }                else                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "C"));                }                // plot style                if (this.chkStyle.Checked && this.cboStyle.SelectedIndex > 0)                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, UTIL.showRscText(rm.GetString("acYES"))));                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, this.cboStyle.SelectedItem.ToString()));                }                else                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "."));                }                // line weights                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, UTIL.showRscText(rm.GetString("acYES"))));                // lineweight with plot scale                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                // paper space object first                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                // hide paper space object                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                // plot file                string outFile = savePath;                if (this.cboPrinter.SelectedItem.ToString().ToUpper().Contains("DWF"))                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, outFile.Remove(outFile.Length - 4) + " " + LayoutManager.Current.CurrentLayout + ".dwf"));                }                else if (this.cboPrinter.SelectedItem.ToString().ToUpper().Contains("PDF"))                {                    if (!this.cboPrinter.SelectedItem.ToString().ToUpper().StartsWith("DWG TO PDF"))                    {                        buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                    }                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, outFile.Remove(outFile.Length - 4) + " " + LayoutManager.Current.CurrentLayout + ".pdf"));                }                else                {                    buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                }                // save changes to page setup                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, "N"));                // proceed with plot                buffer.Add(new Autodesk.AutoCAD.DatabaseServices.TypedValue(RTSTR, UTIL.showRscText(rm.GetString("acYES"))));                                // No error message but not working                //acedCmd(buffer.UnmanagedObject);                                 // Both not working, error message                //doc.Editor.Command(buffer.UnmanagedObject);                doc.Editor.CommandAsync(buffer.UnmanagedObject);            }        }

Navigation

[0] Message Index

[#] Next page

Go to full version