.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to pass parameter in interface to the programe of .dll file using c#?

8 REPLIES 8
Reply
Message 1 of 9
dreamwtx
1972 Views, 8 Replies

How to pass parameter in interface to the programe of .dll file using c#?

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

8 REPLIES 8
Message 2 of 9
MarkPendergraft
in reply to: dreamwtx

What interface did you develop?  Is it a ribbon? tool palette? Is it an external program?

 

-Mark

Message 3 of 9
dreamwtx
in reply to: MarkPendergraft


@MarkPendergraft 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#.


 

Message 4 of 9
MarkPendergraft
in reply to: dreamwtx

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

 

Message 5 of 9
dreamwtx
in reply to: MarkPendergraft

Thank you

Message 6 of 9
Hallex
in reply to: dreamwtx

Show us your code you get started with

maybe it will be more effective

 

~"J"~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 7 of 9
dreamwtx
in reply to: Hallex

  1. 未命名.jpg

  2. 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");

  3.           

        TurnLayyerOff  is .dll file.but i can't pass textBox2.text to the ,dll file.

Message 8 of 9
Hallex
in reply to: dreamwtx

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'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 9 of 9
dreamwtx
in reply to: dreamwtx

there is an error  "HRESULT:0x80010001 (RPC_E_CALL_REJECTED"

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost