I failed to automate TopSolid with both visual c++ 6.0 and visual c++ 2005. The problem is wheneve I invoke any method or property of the IDocument object a "Member not found" exception is fired. It seems that I did not retrieve the IDocument object properly(see codes below). Any idea about it?
Code: Select all
IApplication app;
IDocuments docs;
IDocumentDesign doc;
app.CreateDispatch("TopSolid.Application");
app.SetVisible(TRUE);
docs.AttachDispatch(app.GetDocuments());
doc.AttachDispatch(docs.Add("top"));
// a design document created here successfully
CString msg;
msg.Format("Version No.: %d", app.GetVersion());
AfxMessageBox(msg);
// ok the version number is correct
msg.Format("Current document count is %d", docs.GetCount());
AfxMessageBox(msg); // yes it's alright
doc.GetCurves();
// or any other method or property, "Member not found" error here