I have developped the interface using c#,i want to turn off or on the layer according to the parameter in interface.
now i have carried out turn off or on a specified layer using a .dll file. but how i can connect the parameter in interface to the program in .dll file .thanks
@Anonymous wrote:What interface did you develop? Is it a ribbon? tool palette? Is it an external program?
-Mark
yes ,it is anexternal program. the interface is developped using c#.
If it's an external program, then you need to use the COM API to access functionality inside autocad from your external program.
Take a look here for someone with the same idea:
http://forums.autodesk.com/t5/NET/Stand-alone-applications/m-p/2513610/highlight/true#M15108
You can also search for stand alone applications. There has been a lot of discussion on this type of thing, but it's not something I've ever explored.
-Mark
Show us your code you get started with
maybe it will be more effective
~"J"~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
using Autodesk.AutoCAD;
using System.IO;
//using Autodesk.AutoCAD.ApplicationServices;
//using Autodesk.AutoCAD.DatabaseServices;
//using Autodesk.AutoCAD.Runtime;
//using TurnLayerOff;
namespace Demo
{
public partial class Form1 : Form
{
private AcadApplication a;//声明AutoCAD对象
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
a = new AcadApplicationClass();
a.Visible = true;
string strFileName = "C:\\G4P4-S01.dwg";
a.Application.Update();//更新显示
a.Application.Documents.Open(strFileName, false, 1);
//Autodesk.AutoCAD.Interop.AcadDocument aDocument;
//Autodesk.AutoCAD.Interop.Common.AcadLayers acDoc;
//a.ActiveDocument.Layers.Item("IN_SWGEAR_CAB_USED").LayerOn=false;
//AcadDocument acDocComObj;
//acDocComObj = acAppComObj.ActiveDocument;
// Optionally, load your assembly and start your command or if your assembly
// is demandloaded, simply start the command of your in-process assembly.
a.ActiveDocument.SendCommand("(command " + (char)34 + "NETLOAD" + (char)34 + " " +
(char)34 + "c:/myapps/mycommands.dll" + (char)34 + ") ");
TurnLayerOff.Class1.TurnLayerOff(textBox2.Text);
a.ActiveDocument.SendCommand("TurnLayerOff");
TurnLayyerOff is .dll file.but i can't pass textBox2.text to the ,dll file.
You may want to use direct access to all
AutoCAD objects this way instead:
{ a = new AcadApplicationClass(); a.Visible = true; string strFileName = @"C:\G4P4-S01.dwg"; a.Application.Documents.Open(strFileName, false, 1); AcadApplication acad = (AcadApplication)a as AcadApplication; acad.WindowState = AcWindowState.acMax; AcadDocument adoc = (AcadDocument)acad.ActiveDocument as AcadDocument; AcadUtility acutil = (AcadUtility)adoc.Utility as AcadUtility; string layername = textBox2.Text; acutil.Prompt(string.Format("\nLAYER SELECTED\t{0}",layername)); AcadLayers aclayers = (AcadLayers)adoc.Layers; AcadLayer aclayer = aclayers.Item(layername) as AcadLayer; if (aclayer == null) { MessageBox.Show("Layer \"{0}\" does not exist, try another layer name"); this.textBox2.Select(); this.textBox2.Text = string.Empty; return; } if (aclayer.ObjectID == adoc.ActiveLayer.ObjectID) { MessageBox.Show("This is active layer, program exiting..."); return; } if (aclayer.LayerOn) aclayer.LayerOn = false; acutil.Prompt(string.Format("\n\tLAYER \"{0}\" IS OFF", layername)); }
~'J'~
Can't find what you're looking for? Ask the community or share your knowledge.