Appearance.addByCopy is still fuzzy

Appearance.addByCopy is still fuzzy

VismantasKizelis
Enthusiast Enthusiast
477 Views
2 Replies
Message 1 of 3

Appearance.addByCopy is still fuzzy

VismantasKizelis
Enthusiast
Enthusiast

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()))

 

0 Likes
478 Views
2 Replies
Replies (2)
Message 2 of 3

goyals
Autodesk
Autodesk

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
0 Likes
Message 3 of 3

VismantasKizelis
Enthusiast
Enthusiast

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.

0 Likes