Error in a macro

Hello

Using a macro I insert a component like this:

   Set swComponent = swModel.AddComponent5(TbResultPath.Text, swAddComponentConfigOptions_CurrentSelectedConfig, "", False, "", 0, 0, 0)

 

The problem is that the first time I run the macro I open the component to be inserted, then I go back into the assembly and insert it. But I get this result:

 

And if I restart the macro after clicking on End, it works... I don't understand why.

 

Thank you

Logically, by clicking on "Debug", Sw gives you the line that is causing the problem.

Can you tell us which one?

 

Is the component called in the right place?

 

Edit: An answer here  https://support.microsoft.com/en-us/kb/175616

 

What is the version of Sw and the configuration of your computer?

2 Likes

This is precisely the line I indicated (With the error in capture)

 

>Set swComponent = swModel.AddComponent5(TbResultPath.Text, swAddComponentConfigOptions_CurrentSelectedConfig, "", False, "", 0, 0, 0)

 

Edit: Thanks for the link, but I don't really understand what I can get out of it.

 

Then I'm on Windows 7 64, SW2013.

I'm not an expert in macro...

 

Lucas would surely be able to help you.

 

By chance, shouldn't we put Tbb instead of Tb?

1 Like

Hum I managed to solve my problem but I don't know how (well especially why).

 

Before my insertion, I was going back to my assembly. But if I go back to my assembly BEFORE calling this method, it works... I don't understand why.

 

But thank you very much for your help!

>

Hum I managed to solve my problem but I don't know how (well especially why).

 

Before my insertion, I was going back to my assembly. But if I go back to my assembly BEFORE calling this method, it works... I don't understand why.

 

But thank you very much for your help!

Hello

I think it's the insertion that takes longer than expected, and that you have to pause (wait) so that it finishes opening the component before inserting it.

If we click on Debug, does swModel point to an assembly or to a part?

I think it's a play...

For several solutions for breaks, see here:

http://www.lynkoa.com/forum/3d/affichage-de-configurations-avec-tempo

 

2 Likes

It confirms what I thought, you weren't on the assembly when inserting the component!

2 Likes

There you go, I knew that lucas would find the right answer! =)

3 Likes