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

ResultBuffer and Application.Invoke

1 REPLY 1
Reply
Message 1 of 2
Blarran
936 Views, 1 Reply

ResultBuffer and Application.Invoke

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;
}

 

1 REPLY 1
Message 2 of 2
augusto.goncalves
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
Twitter @augustomaia
Autodesk Developer Network

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