I am trying to pull a variable out of a Windows Forms page created in one application and pass it into an AutoCAD C# .Net function I have written.
I am able to assign the value in the TextBox
blockNameInput to another variable. I need to get that same information into AutoCAD so that I can then load all blocks with that name.
I have a class with properties for the blockName that I am setting and getting the value for. It all works in the same namespace. When I call the same variable in a different namespace, I get the default value "Old" instead of the value that was input into the TextBox.
I may be starting a new instance of BlockNameClass in the second namespace, but I have no idea what the solution could be. The relevant code is below:
//THIS IS THE OUT OF PROCESS AUTOCAD SCRIPT
namespace AttributeSyncExternal
{
public partial class AttributeSyncForm : Form, IMessageFilter
{
public class BlockNameClass
{
public string blockName = "Old";
public string BlockName
{
get
{
return blockName;
}
set
{
blockName = value;
}
}
}
public static readonly BlockNameClass _class = new BlockNameClass();
public static BlockNameClass BlockNameClassInstance
{
get { return _class; }
}
private void runButton_Click(object sender, EventArgs e)
{
BlockNameClassInstance.BlockName = blockNameInput.Text;
//DO SOME OTHER STUFF HERE
}
}
}
using static AttributeSyncExternal.AttributeSyncForm;
//THIS IS THE IN PROCESS AUTOCAD SCRIPT
namespace AttributeSyncExternal.Attributesync
{
public class DumpAttributes
{
[CommandMethod("LISTATT")]
public void ListAttributes()
{
//DO SOME OTHER STUFF HERE
string blockName = BlockNameClassInstance.BlockName;
}
}
}