Message 1 of 5
AcadApplication
Not applicable
09-21-2008
07:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
je cherche un code en c # qui permet de tester si autocad est ouvert pour ne pas le relancer et récupérer le model space.
la commande " AcadApplication app = new AcadApplication()" permet de lancer autocad mais je veux éliminer cette étape et utiliser mon model space.
voici le code que je veux le modifier
using System;
using Autodesk.AutoCAD.Runtime;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
//using App = Autodesk.AutoCAD.ApplicationServices.Application;
[assembly: CommandClass(typeof(ClassLibrary.civiClass))]
namespace ClassLibrary
{
///
/// Summary description for civiClass.
///
public class civiClass
{
[CommandMethod("line")]
public void line() // This method can have any name
{
AcadApplication app = new AcadApplication();
AcadDocument doc1 = app.ActiveDocument;
//This example adds a line in model space
AcadLine lineObj;
double[] startPoint = new double[3];
double[] endPoint = new double[3];
//Define the start and end points for the line
startPoint[0] = 1; startPoint[1] = 1; startPoint[2] = 0;
endPoint[0] = 50; endPoint[1] = 200; endPoint[2] = 0;
//Create the line in model space
lineObj = doc1.ModelSpace.AddLine(startPoint, endPoint);
app.Application.Visible = true;
doc1.Regen(AcRegenType.acAllViewports);
app.ZoomAll();
}
}
}
merci
la commande " AcadApplication app = new AcadApplication()" permet de lancer autocad mais je veux éliminer cette étape et utiliser mon model space.
voici le code que je veux le modifier
using System;
using Autodesk.AutoCAD.Runtime;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
//using App = Autodesk.AutoCAD.ApplicationServices.Application;
[assembly: CommandClass(typeof(ClassLibrary.civiClass))]
namespace ClassLibrary
{
///
/// Summary description for civiClass.
///
public class civiClass
{
[CommandMethod("line")]
public void line() // This method can have any name
{
AcadApplication app = new AcadApplication();
AcadDocument doc1 = app.ActiveDocument;
//This example adds a line in model space
AcadLine lineObj;
double[] startPoint = new double[3];
double[] endPoint = new double[3];
//Define the start and end points for the line
startPoint[0] = 1; startPoint[1] = 1; startPoint[2] = 0;
endPoint[0] = 50; endPoint[1] = 200; endPoint[2] = 0;
//Create the line in model space
lineObj = doc1.ModelSpace.AddLine(startPoint, endPoint);
app.Application.Visible = true;
doc1.Regen(AcRegenType.acAllViewports);
app.ZoomAll();
}
}
}
merci