Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Appearance.addByCopy is still fuzzy

2 REPLIES 2
Reply
Message 1 of 3
VismantasKizelis
206 Views, 2 Replies

Appearance.addByCopy is still fuzzy

Hello.

 

Some time ago I've posted this about malfunction of Appearance.addByCopy. The issue was fixed in November 28, 2018 Product Update. However, I'm still facing some problems about copying appearances. The thing is, that when I try to make a copy of existing appearance in design, then source appearance disappears.

 

The py script is:

import adsk.core, adsk.fusion, adsk.cam, traceback

 

def run(context):

ui = None

try:

app = adsk.core.Application.get()

ui = app.userInterface

materialLibs = app.materialLibraries

matLib = materialLibs.item(1)

appear = matLib.appearances.item(0)

 

des = adsk.fusion.Design.cast(app.activeProduct)

 

appear1 = des.appearances.addByCopy(appear, "A")

#Having appearance named "A" in desing

 

#Let's make copy of appearance "A" and name it "A1"

appear2 = des.appearances.addByCopy(appear1, "A1")

#Having appearance named "A1" in desing. Appearance "A" disappeared!!!

 

except:

 

if ui:

ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

2 REPLIES 2
Message 2 of 3
goyals
in reply to: VismantasKizelis

I agree it is not working if you try to add an another copy from already copied appearance but the fix is working for below code. Ideally solution should worked for all the combinations but not sure if it is really a blocker.

 

appear1 = des.appearances.addByCopy(appear, "A")

 

appear2 = des.appearances.addByCopy(appear, "A1")



Shyam Goyal
Sr. Software Dev. Manager
Message 3 of 3
VismantasKizelis
in reply to: goyals

Unfortunately I have an error with your suggested solution.

After some research I find out that the problem appears when using custom created appearance library. The key is not to have appearance asset in design with same name as it exists in library.

 

Steps to reproduce:

  1. Using Material Browser create new library "testLib";
  2. Create new appearance "testAppearance" in that lib (I created wood appearance. Don't know if it depends on type)
  3. Run the script:

matLib = materialLibs.itemByName("testLib")

appear = matLib.appearances.itemByName("testAppearance")

des.appearances.addByCopy(appear, "testAppearance") #copy asset by providing original name

des.appearances.addByCopy(appear, "testAppearance_1") #InternalValidationError : assetInst

 

 

 

 

To make my code work for now I just check appearances in design before copying a new one from library. If appearance with same name is found, then I just rename it in design. Not the most elegant solution, but it works.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report