本文介绍了SolidWorks API和Winforms C#swApp(独立)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是solidworks
告诉您要做的对swApp
的引用,但是我一直在引用它的行上得到NullReferenceException
.
This is what solidworks
tells you to do to reference swApp
, but I keep getting NullReferenceException
on the line that it is referenced.
有人知道为什么吗?或我该如何修理?
Does anyone have any idea why? or How I go about repairing?
我可以稍后引用它吗,例如swApp = ????
Can I reference it later on such as swApp = ????
private void button5_Click(object sender, EventArgs e)
{
//Save Drawing
ModelDoc2 swDoc = null;
int longstatus = 0;
swDoc = ((ModelDoc2)(swApp.ActiveDoc));
longstatus = swDoc.SaveAs3(
@"C:\Engineering\Engineering\SW Automation\Linear Actuator Technology\MLD Series\Prints\Configured Prints\" +
textBox1.Text + ".SLDDRW", 0, 2);
}
public SldWorks swApp;
推荐答案
想通了,谢谢大家的帮助.
Figured it out thanks for the help everyone.
SldWorks swApp = null;
swApp = (SldWorks)Activator.CreateInstance(
Type.GetTypeFromProgID("SldWorks.Application"));
这篇关于SolidWorks API和Winforms C#swApp(独立)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!