Import Image doesn't work (returns with false)

Import Image doesn't work (returns with false)

Anonymous
Not applicable
1,238 Views
8 Replies
Message 1 of 9

Import Image doesn't work (returns with false)

Anonymous
Not applicable

Hello,

 

I already searched the forum, but couldn't find anythink helpful for me.

 

We are importing images into the revit document via Document.Import(...)

When we do so, in some cases (dependent on document) the API method fails and return with false.

We have some customer, complaining that our addon is not working correctly, but can't help them as we don't see any reason why the import fails and don't know how we could "repair" their documents.

 

I added a test project with a macro inside.

Reproduce:

* put the test.png to C:\temp\test.png (or edit the absolute path in the macro)

* Open ImportOfImageFails.rvt and load/compile the macro Test.InsertImage

* run the macro

 

Expectation:

* test.png can be inserted (GNU appears)

 

Failure:

* Document.Insert fails with return false

 

If you afterwards insert any image (e.g. the cc.png) via "Image" command in "Insert"-Ribbon the test.png (GNU) appears multiple times together with the cc.png. If you now delete all the images and run the macro again the test.png (GNU) will appear correctly.

 

Harald

0 Likes
1,239 Views
8 Replies
Replies (8)
Message 2 of 9

jeremytammik
Autodesk
Autodesk

Dear Harald,

 

Thank you for your report.

 

I am sorry that thread was not picked up by earlier.

 

As I explained in the ADN case answer, the preferred method to submit non-confidential ADN queries or requests on the Revit API like this is indeed via the Revit API discussion forum.

 

Any thread that you submit there using your email address registered as an ADN member will be recognised as such and automatically escalated to us in the ADN team.

 

At the same time, you will address a larger audience, more of your peers will see it, be able to chip in and help, and more people will see and profit from the answers we provide.

 

We therefore prioritise cases from the discussion forum.

 

Please submit all your non-confidential queries via the Revit API discussion forum.

 

I assume that this thread was submitted with an email address that is not registered as an ADN member.

 

You can ask your administrator to list the email address you use in the forum as an ADN member, or use an existing email address that is already registered as an ADN member to submit queries to the discussion forum, so they will be automatically escalated to ADN if they remain unanswered for a little while.

 

Concerning your report:

 

Sorry to hear about this strange behaviour.

 

I logged the issue REVIT-133228 [Document.Import PNG file fails and returns false -- 14320365] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 9

Anonymous
Not applicable

Hi, 

I finally found the reason. If the Model Category "Raster Image" is not active, the Document.Import(...) method returns always with false.

This seems to me, to be an unusual behavior. Usually the creation of the object (Pipe, Walls, FamilyInstances) has nothing to do that it won't be visible. I am wrong?

I think it would be a good idea to extend the API-documentation for Document.Import(...), as it currently only states:

"Import Method (String, ImageImportOptions, View, Element)

 
Harald
0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Dear Harald,

 

Thank you for sharing this important and unexpected observation.

 

I passed it on to the development team for you.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 9

jeremytammik
Autodesk
Autodesk

... At first glance, they consider it a possible bug...

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 6 of 9

jeremytammik
Autodesk
Autodesk

Dear Harald,

 

Thank you for your research and explaining this behaviour.

 

I think this makes perfect sense.

 

The development team responded to the development ticket REVIT-134676 [Document.Import PNG file fails and returns false -- 14320365] and say:

 

This will not be consistent. Images are not the same as Pipes, Walls, etc.

 

Raster images are current-view-only 2D elements that cannot be placed on 3D views and are not visible in any other views than the views they are placed. 'Raster image' in the Model category visibility dialog is a legacy UI problem that is misleading.

 

I want to clarify that it will not be the same as the other categories listed and hope that the customer understands that. They will not be able to be placed in 3d views or schedules or any other place images are prevented in the UI.

 

I also want to confirm that the problem use case is not one of these special cases. Does the problem occur in a plan view or other supported view? Does the use case also take into account that the image should be placed only in the current view? Perhaps there is no suitable current view activated?

 

Can you expand on your suggestion for enhancing the documentation, please?

 

What do you think it should say?

 

Thank you!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 9

jeremytammik
Autodesk
Autodesk

Dear Harald,

 

Thank you for your patience with this.

 

The development team explored the behaviour further. They apparently made some slight changes to fix and close the development ticket REVIT-134676 [Document.Import PNG file fails and returns false -- 14320365] and explain:

 

Focusing in on the comment "If you afterwards insert another image cc.png via the "Image" command in the "Insert" ribbon, the test.png appears multiple times together with the cc.png. If you now delete all the images and run the macro again, the test.png will appear correctly."

 

This is easy to explain.

 

In the sample RVT, the "raster" category is turned off. If you turn it on, you will see all the other images imported and stacked up.

 

If you run the macro with the raster image category on, the macro will work in Revit 2019; with it off, it will fail.

 

In Revit 2019, if you place an image in a view that has raster image off, Revit will silently turn it on, so you can see and place the image. This is why the macro works after placing an image in 2019.

 

So, a workaround in 2019 is to have the macro check and turn on the raster category and it will work. I assume placing invisible images would be a very low priority.

 

In Revit 2020, this changed, so behaviour is slightly different.

 

We removed the non-standard behaviour of the raster category secretly turning itself on.

 

This seems to have fixed it. The image is now placed but is not visible with the raster category off and is visible with category on.

 

I hope this clarifies everything.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 9

Anonymous
Not applicable

Hello Jeremy,

 

thanks for your response. We already recognizes that there were changes in 2020 and as far as I know the issue was solved with that release.

 

To explain the what we interpreted as a bug in 2018/2019:

The method returned false ("Import of image was not successful") but if you turned on the visibility the image was there. In my opinion the method should have returned true instead of false.

If this should have been the correct behavior the docu must be changed and needs a hint that the method will also return false if the image could be imported but not visible in the given view.

 

Thanks Harald

0 Likes
Message 9 of 9

jeremytammik
Autodesk
Autodesk

Dear Harald,

 

Thank you for your update and suggestion.

 

I added it to the development ticket REVIT-134676 [Document.Import PNG file fails and returns false -- 14320365].

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes