Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor will only pull in the first element of an item when using API.

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
jack.biggs
541 Views, 10 Replies

Inventor will only pull in the first element of an item when using API.

First of all I want to say any help is appreciated, I am new to the Autodesk ecosystem and trying to fix someone elses work which is never an easy task in itself.

 

The company I work for has previously developed a program that allows the designers to quickly search and select parts and then allows them to drop it straight into an assembly on Inventor. However the program has stopped allowing parts will multiple elements to it to be added. The program will only add the first element in the part to Inventor.

 

I believe the code below is responsible for pulling in the part.

PopUpDialogue.UpdateProgress(10, "Trying to retreive " + sFileName[0]);
                    VDF.Vault.Currency.Connections.Connection m_conn;
                    m_conn = new VDF.Vault.Currency.Connections.Connection(mVault, s, "", "Vault", VDF.Vault.Currency.Connections.Connection.AnonymousUserId, "se-vault01", VDF.Vault.Currency.Connections.AuthenticationFlags.Standard);
                    VDF.Vault.Currency.Entities.FileIteration fileIte;

                    /*Progress 60%*/
                    PopUpDialogue.UpdateProgress(10, "Downloading " + sFileName[0]);
                    fileIte = new VDF.Vault.Currency.Entities.FileIteration(m_conn, acwFile[0]);

                    VDF.Vault.Settings.AcquireFilesSettings mSettings = new VDF.Vault.Settings.AcquireFilesSettings(m_conn);
                    // try
                    // {

                    mSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeChildren = true;
                    mSettings.OptionsRelationshipGathering.FileRelationshipSettings.RecurseChildren = true;
                    mSettings.OptionsRelationshipGathering.FileRelationshipSettings.IncludeLibraryContents = true;
                    mSettings.OptionsRelationshipGathering.FileRelationshipSettings.VersionGatheringOption =
                        VDF.Vault.Currency.VersionGatheringOption.Latest;
                    

                    /*Progress 70%*/
                    PopUpDialogue.UpdateProgress(10, "Aquiring  " + sFileName[0]);
                    VDF.Vault.Results.AcquireFilesResults results = m_conn.FileManager.AcquireFiles(mSettings);

 

I have attached a screen recording.

Labels (3)
10 REPLIES 10
Message 2 of 11
Ralf_Krieg
in reply to: jack.biggs

Hello

 

It's not clear to me (and maybe some others) what you mean. Is the placed part not the part previous selected in the dialog? Should this be an assembly with the complete enclosure, but placed is only one single part of this enclosure? Or is the problem that you can only place one occurrence?


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 3 of 11
jack.biggs
in reply to: Ralf_Krieg

Thanks for your reply, Kreig. My apologies for not being clearer.

 

It's the first (alphabetical) element in the assembly of the part previously selected in the dialogue.

It's not bringing in the whole part/assembly.

Message 4 of 11
jjstr8
in reply to: jack.biggs

I'm assuming that the initial selection is an assembly file and that your acquire from Vault is meant to ensure that the assembly file and all associated parts are available locally.  I can't see where you're doing the actual place command, but I suspect that you're using an element in the AcquireFiles result.  Since the results are a collection and you don't know the path to the selected assembly, you'll need to search the results for a match.  I don't believe that AcquireFiles for an assembly plus dependents guarantees that the assembly is the first element in the results collection.

Message 5 of 11
Ralf_Krieg
in reply to: jack.biggs

Hello

 

I think you should set stop point in your debugger and check the value of sFilename[0] after clicking "cmdRetrieve" button. It's the first item in the array and I agree to @jjstr8 that this is not the name of the assembly you selected in the GUI. If at this stop point the value of sFileName[0] is correct, check is elsewhere after this value is overwritten.


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 6 of 11
jack.biggs
in reply to: jjstr8

When I look at the local location for where the part is made available, it's only got one part in. So the place command only has 1 part to place. I don't understand why it's not bringing any other parts in.

 

If you need any other parts of the code, please let me know.

Message 7 of 11
Ralf_Krieg
in reply to: jack.biggs

Hello

 

It's difficult to say post this or this part of code as we don't know the whole project. On other hand I understand that it's not possible to post the complete project. So we have to search step by step and hope we walk the right direction.

I would delete the one downloaded file and check in an new run if it is downloaded again and it's the only one. This will also guarantee that the vault connection is working.

Next add a stop point in your code before aquiring the files from vault and check the value of acwFile[0]. It seems there should be the filename of the selected enclosure assembly. If not, check why.

 

Hopefully we found within the results the solution or a hint for next questions.


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 8 of 11
jjstr8
in reply to: jack.biggs

@jack.biggs, The place command only places one component, either a part or an assembly.  From your video, it certainly looks like the final selection should be an assembly even though it's called a part on the dialog box.  As I mentioned previously, you'll need to determine the filename and path to the local assembly file.  That's what the place command needs.  Here's a couple of things to check:

 

  • Set a breakpoint on your Retrieve Part button click.  Check what the selection eventually feeds the AcquireFiles method.
  • Set a breakpoint on the AcquireFiles call and check the results after the call.  Look at the FileResults and see what's listed.
Message 9 of 11
jack.biggs
in reply to: jack.biggs

Sorry for the delay in replies, I only work part time.

 

So I've narrowed it down to these 3 lines where it all goes wrong.

VDF.Vault.Currency.Entities.FileIteration fileIte;

                    /*Progress 60%*/
                    PopUpDialogue.UpdateProgress(10, "Downloading " + sFileName[0]);
                    fileIte = new VDF.Vault.Currency.Entities.FileIteration(m_conn, acwFile[0]);

 fileIte becomes as @jjstr8 said, a completely random part within the assembly folder in Vault.

 

I'm at a loss as to what to do next.

Message 10 of 11
jjstr8
in reply to: jack.biggs

You're not really giving us a lot to go on.  Look at the two items in my last post that I suggested to check.  Without more information, I can only assume acwFile[0] is the result of a search such as FindLatestFilesByPaths.  Is it really the assembly file your trying to acquire?  Does it show up in the AcquireFileResults?  Why doesn't your code just convert the acwFile[0] Vault path to a local path for inserting the assembly?

 

 

Message 11 of 11
jack.biggs
in reply to: jack.biggs

I fixed it by adding a new search before the original search with a new search condition specifically looking for Assembly files. If it found the single assy file in the Vault file path that becomes acwFile[0], it it's empty it run the original search which will find a singular part file for parts such as screws.

 

Thanks for all the guidance guys.

 

SrchCond isAssy = new SrchCond()
                    {
                        SrchTxt = ".iam",
                        SrchOper = 1,
                        SrchRule = SearchRuleType.Must,
                        PropTyp = PropertySearchType.AllProperties
                    };

                    string bookmark = string.Empty;
                    SrchStatus status = null;
                    acwFile = mVault.DocumentService.FindFilesBySearchConditions(new SrchCond[] { noMIR, noDWF, isAssy }, null, iFolder, false, false, ref bookmark, out status);
                    try
                    {
                        mVault.DocumentService.GetFileById(acwFile[0].Id);
                    }
                    catch
                    {
                        //MessageBox.Show("No Assembly File");
                        isAssembly = false;
                    }
                    if (isAssembly == false)
                    {
                        acwFile = mVault.DocumentService.FindFilesBySearchConditions(new SrchCond[] { noMIR, noDWF }, null, iFolder, false, false, ref bookmark, out status);
                        mVault.DocumentService.GetFileById(acwFile[0].Id);
                        //MessageBox.Show("File in vault " + acwFile[0].Name.ToString());
                        try
                        {

                        }
                        catch
                        {
                            MessageBox.Show(sFileName[0] + " not located on the Vault, please ensure it has been added to the correct Vault", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);
                            PopUpDialogue.CloseDialogue();
                            return;
                        }

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report