×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Adding component to a new assembly document

Adding component to a new assembly document

Adding component to a new assembly document

(OP)
Hi!  

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

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.

RE: Adding component to a new assembly document

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

RE: Adding component to a new assembly document

(OP)
Sorry my late response, I was without a computer...

Before I'm searching the web, and found a link:
http://216.239.59.104/search?q=cache:_rX7lDOJWXkJ:www.tutorials-we.com/SOLIDWORKS/inserting-component/+Solidworks+AddComponent4&amp;hl=hu&amp;ct=clnk&cd=3&gl=hu

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! smile
ZsZs.

RE: Adding component to a new assembly document

Have you downloaded the Solidworks SDK?

RE: Adding component to a new assembly document

(OP)
Yes, why?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources