Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding component to a new assembly document

Status
Not open for further replies.

ZsZs

Computer
May 8, 2007
30
Hi!

I create a new assembly doc (from my C++ program) and I like adding by assembly component to it.
But don't work... :-(

I like the adding the component to the assembly by the
AddComponent4() function.
The function result:
hres = S_OK (it's good) but a pointer to the component is NULL (variable name of program: swComp). It is bad.

My codesnippet:

IComponent2* swComp;
CComQIPtr <IAssemblyDoc> swAssy = swModel;
hres = swAssy -> AddComponent4(component_name, "", x, y, z, &swComp);

Why???
Can anybody a idea? (swAssy is correct too...)
(Sorry the my C++ example, but I not working properly in VB...)

Thanks:
ZsZs.
 
Replies continue below

Recommended for you

The remarks section of the API help for AddComponent4 says that the file specified by compName must already be loaded into memory prior to the call to the AddComponent4 call. It suggests using the SldWorks::OpenDoc6 method.

Eric
 
Sorry my late response, I was without a computer...

Before I'm searching the web, and found a link:

There is wrote also the firs possible solution the using the OpenDoc6().

The second chance the using the IAddComponents2() functions.
(It is possible quickly? - not explicit open... or the backgound open effecting equal speed? - I don't know...)

Now, but I big problem with this method that have the in the source a declaration:
LPCOMPONENT swCompArr[2] = {NULL, NULL};
My compiler (Visual C++ 6.0 Pro) not found the LPCOMPONENT type, and write a error message for me. Where is it? Which include file? Or what do it the variable?
I not found the type between the C++ header files, I belive it is a Solidworks API type... or not?

(In the Solidworks API help, by the IAddComponent2, only C++ example...)

Thanks your suggestions! :)
ZsZs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor