Hi!
I create a new assembly doc (from my C++ program) and I likeaddingby assembly component to it.
But don't work... :-(
My codesnippet:
IDispatch* swDisp;
hres =swApp->NewDocument(C_BSTR::to_BSTR(templatedoc),swDwgPaperAsize,0, 0, &swDisp);
if((hres == S_OK) && (swDisp))
{
hres =swDisp->QueryInterface(IID_IModelDoc2,(void**)&swModel);
if((hres == S_OK) && (swModel))
{
IComponent2* swComp; CComQIPtrswAssy = swModel;
hres=swAssy->AddComponent4(C_BSTR::to_BSTR(component_name),_bstr_t(""),x, y, z, &swComp);
if ((hres == S_OK) && (swComp))
{
cout << "OK." << endl;
}
}
}
It work to swAssy value.
In the hres = swAssy->AddComponent4( ... ) row the hres =S_OK(it's good!) but swComp variable is NULL! (it's bad value!)
Why???
Can anybody a idea?
(Sorry the my C++ example, but I not working properly inVB...)
Thanks:
ZsZs.
SolidworksApi macros







I create a new assembly doc (from my C++ program) and I likeaddingby assembly component to it.
But don't work... :-(
My codesnippet:
IDispatch* swDisp;
hres =swApp->NewDocument(C_BSTR::to_BSTR(templatedoc),swDwgPaperAsize,0, 0, &swDisp);
if((hres == S_OK) && (swDisp))
{
hres =swDisp->QueryInterface(IID_IModelDoc2,(void**)&swModel);
if((hres == S_OK) && (swModel))
{
IComponent2* swComp; CComQIPtr
hres=swAssy->AddComponent4(C_BSTR::to_BSTR(component_name),_bstr_t(""),x, y, z, &swComp);
if ((hres == S_OK) && (swComp))
{
cout << "OK." << endl;
}
}
}
It work to swAssy value.
In the hres = swAssy->AddComponent4( ... ) row the hres =S_OK(it's good!) but swComp variable is NULL! (it's bad value!)
Why???
Can anybody a idea?
(Sorry the my C++ example, but I not working properly inVB...)
Thanks:
ZsZs.
SolidworksApi macros
