Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Add-In Only Error: ImportToTarget Run Time Error: pBase

jakedbirk
Enthusiast

Add-In Only Error: ImportToTarget Run Time Error: pBase

jakedbirk
Enthusiast
Enthusiast

Hello, 

 

I've been working on an add-in that occasionally requires .f3d files be imported into the active document.

 

I've gotten this feature to work perfectly when I only have to import a singular .f3d document but gives me an error (which I will include below) whenever I try to import multiple f3d files within the same execute. I do not get an error when I only import a single file in that execution and can run the add-in as many times as I'd like in the same document.

 

I have been trying to isolate/solve this error for about two days. I was extremely frustrated when I could not replicate the error in a sample script, which I often do before I post a question to the forums. I eventually tried avoiding this error in so many ways that I was confident it was not something with my specific add-in that was causing the issue: this is when I copied and pasted the code into a fresh add-in (the demo add-in that automatically created through the "Scripts and Add-Ins" command when you make a new add-in. 

 

The following snippet of code will cause an error when pasted into the onExecute section/class of an add-in, but will run fine with a script: 

pathNewel = 'C:/Users/jaked/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/AddIns/AStairGramF360AddIn/resources/3dData/newels/starterNewelModern Notched.f3d' #I've attached this file in my post, but you can probably replace it with any .f3d file path you happen to have.
        importMgr = app.importManager
        importNewel = importMgr.createFusionArchiveImportOptions(pathNewel)
        importMgr.importToTarget2(importNewel,rootComp)
        importMgr.importToTarget2(importNewel,rootComp) #If this line is commented out, the code runs, if not, it throws the error.

 

There are two possible error codes it gives when this happens. The one that I've dealt with far more commonly is the pBase error. The error code it picks seems to be random:

birkmaij_0-1694223399948.png

 

birkmaij_1-1694223741815.png

 

The no RTTI data! error can sometimes be induced by running the add-in after recently restarting f360. 

 

I think part of my problem is that I don't know what either of these error codes mean, is there somewhere I can look up the error code meanings? I googled "F360 API pBase error" and haven't gotten any results. 

 

A few things I've already tried to solve/workaround this are:

* re assigning all of the varibles in almost any order you can think of

* trying it with a new component

* trying it with it making a new component within the importToTarget() function

* trying to put other things in between the two imports 

* trying to use different target components

* trying to use importToTarget2() for one and importToTarget() for another 

* trying to use two different .f3d files

* trying a try loop within a while True loop (this was obviously a bad idea but the concept was to give the program time (this was a horrible idea))

* Putting the whole thing into a function 

* putting just some parts into a function 

None of those worked. 

 

I'm excited to hear back about what the cause of this issue is and what some solutions/workarounds can be. 

 

My use case is importing different newel posts and eventually balusters into a staircase design and requires zero to multiple offline 3D objects (newels and balusters) to be imported into a child component in the document and then manipulated afterward (to notch them/apply appearance/put them in the correct space. Sometimes the 3D objects are the same and sometimes there could be several different objects that need to be imported, none of which are the same (depending on the staircase design). 

 

I am anticipating this to be a challenging problem and very much appreciate any help that can be offered!

 

If needed I can upload the sample Add-in I created, but it will probably be easier to just copy and paste the code into an existing add-in on a local machine for testing purposes.

0 Likes
Reply
Accepted solutions (1)
364 Views
2 Replies
Replies (2)

BrianEkins
Mentor
Mentor
Accepted solution

I recently learned something that I believe might be the cause of your problem. I learned that the import and maybe export API methods are implemented internally by calling a command. This causes a problem when used within a custom command because when a command is executed, it terminates the currently running command.

 

What I would try is doing the import outside of your command. Your command can still collect all of the information needed, but during the execute event, you would do what you can within the execute event, and anything to do with import or export would save the information so you can do it later. 

 

The trick is when to do it. You can't do it in any of the events related to your command because it is still running. Instead, in your command's destroy event, you can fire a custom event. A custom event is queued on Fusion's event queue, and when Fusion gets a chance to handle events, it will be processed. This means your command will have a chance to finish before Fusion fires the custom event. You'll also create an event handler for the custom event; in that handler, you can import the files. Besides being much more complex, the downside to this is that everything done outside the command won't be wrapped in the same transaction as your command. This means there will be several undo steps to get back before your command.

 

Custom events are described here, but it's focused on how they're used with another thread. You won't need to create a new thread but will just be firing the custom event and then handling the event.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
2 Likes

jakedbirk
Enthusiast
Enthusiast

That solution worked well, I seem to be able to import as many .f3d objects as needed. 


Thank you for helping me solve this problem, Another great feature has been contributed to my add-in!

0 Likes