.NET

Reply
Contributor
Blarran
Posts: 15
Registered: ‎07-30-2012
Message 1 of 2 (86 Views)

ResultBuffer and Application.Invoke

86 Views, 1 Replies
08-13-2014 12:44 PM

I'm trying to understand how to send commands using ResultBuffer and Application.Invoke.

 

I want to be able to jump (or surf) to a component in Autocad Electrical from another application that has a DataGridView. When user clicks on a row, AE jumps to the location of the component in question.

 

I wrote test code to figure out how to use the ResultBuffer and Application.Invoke. I couldn't get it to work. The work around is to send the commands using SendStringToExecute().

 

Can someone tell me what I'm doing wrong with setting up the ResultBuffer?

 

Thanks.

 

[CommandMethod("TestJump", CommandFlags.Session )]
static public void TestJump()
{
	string path = @"C:\WORK\AUTOCAD ELECTRICAL\SAMPLE PROJECT\33729802004.DWG";
	path = path.Replace(@"\",@"/");
	// JumpTo(path, "7366"); <<<< DOESN"T WORK
	JumpTo2(path, "7366");
}


// DOES NOT WORK
public static void JumpTo(string path,string hdl )
{
	try
	{
		// WHAT IS WRONG???
		ResultBuffer pa = new ResultBuffer();
		pa.Add(new TypedValue(LispUtil.RTSTR, "c:ace_surf_zoom_in_no_dlg"));
		pa.Add(new TypedValue(LispUtil.RTSTR, path));
		pa.Add(new TypedValue(LispUtil.RTSTR, hdl));
		pa.Add(new TypedValue(LispUtil.RTNIL));

		ResultBuffer rb = Application.Invoke(pa);
		Debug.Print(rb.ToString());
	}
	catch (System.Exception ex)
	{
		Debug.Print(ex.Message);
	}
}

// THIS WORKS
public static void JumpTo2(string path, string hdl)
{
	string cmd = "(c:ace_surf_zoom_in_no_dlg \"{0}\" \"{1}\" nil) ";
	cmd = string.Format(cmd, path, hdl);
	var doc = Application.DocumentManager.MdiActiveDocument;
	Application.
	doc.SendStringToExecute(cmd, true, false, true);
	doc = null;
}

 

ADN Support Specialist
augusto.goncalves
Posts: 358
Registered: ‎04-30-2009
Message 2 of 2 (41 Views)

Re: ResultBuffer and Application.Invoke

08-27-2014 01:35 PM in reply to: Blarran

I'm not sure about the type numbers you're using, but I replaced them with the number and seems to work fine:

 

public static void JumpTo(string path, string hdl)
{
  try
  {
    ResultBuffer pa = new ResultBuffer();
    pa.Add(new TypedValue(5005, "c:ace_surf_zoom_in_no_dlg"));
    pa.Add(new TypedValue(5005, path));
    pa.Add(new TypedValue(5005, hdl));
    pa.Add(new TypedValue(5019));

    ResultBuffer rb = Application.Invoke(pa);
    Debug.Print(rb.ToString());
  }
  catch (System.Exception ex)
  {
    Debug.Print(ex.Message);
  }
}
Regards,



Augusto Goncalves
Autodesk Developer Network
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.