Solidworks API 和 Winforms C# swApp(独立)
这就是 solidworks
告诉您引用 swApp
时要做的事情,但我在引用它的行上不断收到 NullReferenceException
。
有谁知道为什么吗?或者我该如何修复?
我可以稍后引用它,例如 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;
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?
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
弄清楚了谢谢大家的帮助。
Figured it out thanks for the help everyone.
在某个地方,您将不得不填充Swapp。我不使用SOLIDWORKS,所以我不能给您确切的代码,而是在其示例代码的构造函数中查看。也许您可以找到一个示例,说明如何在那里填充Swapp。
Somewhere you're going to have to populate swApp. I don't use SolidWorks so I can't give you the exact code but look in the constructor of their example code. Maybe you can find an example of how swApp is populated there.