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: 

Assign appearance to faces at API isn't working ! (isUsed = False)

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Moh_Samy
329 Views, 2 Replies

Assign appearance to faces at API isn't working ! (isUsed = False)

Hi ,

Program overview:

I am writing a program which edits a base design file (Capacitor 3d Model) according to bunch of
inputs from a .CSV file. the design was created using parameters which I simply edit them using the
API program. Beside this, i also edit the appearance of some faces according to the input color
from the .csv file, and here is the problem.

 

Issue:
The problem rises in this specific section of the program (ie : in which i change appearances)

      

---------------------------------------------------------------------------
# after calling the current product and initialization stuff...

# pull features collection
features = rootComp.features.extrudeFeatures

# choose the feature i need as a already editing a pre made model and know each feature's name
feature0 = features.itemByName('Extrude1')

# Grab the faces resulted from this specific feature
faces0 = feature0.faces

#Grab an appearance sample from the ones already exixt in the InDesign Appearances
appearanceSample1 = design.appearances.itemByName('Plastic - Glossy (Blue)')

#apply this appearance to the collection of faces i made earlier
faces0.appearance = appearanceSample1
---------------------------------------------------------------------------


the program is executed without any errors, but no appearances changed !
when i debug the execution, i noticed something which i think is the problem, but it
I couldn't fix it anyhow

the debugging result for the last line >> [faces0.appearance = appearanceSample1] is attached below >>
notice under the appearance tab for "faces0" item, isUsed property value is "False", which according to the
documentation is a ReadOnly property which couldn't be set.

Any help with this ?!

Some notes that may help:

- I tried to debug another model to figure out this isUsed property. i modeled the cube
simply with the Graphical UI by creating a rectangular sketch then extrude it, then adding
a blue appearance to the the endFaces of the extrusion feature.
then i run a code which return the extrude feature end face properties using this simple
line of code [faces0 = feature0.endFaces] (of-course after the initialization stuff :D)
the result of the debugging was that "faces0" collection have the appearance tab with (isUsed = True)
so i need to know how the Graphical UI adds appearances to the faces in the background so, i simulate
this in the API code.

- I noticed the same problem happens when i try to add appearance to the bodies resulted
from a feature [bodies0 = feature0.bodies], it only works when i access the body from
BRepBodies object (ie: [bodies = rootComp.BRepBodies.item(0)]), so it might help if there is a way
to access the faces result from the feature using the BRepFaces object. Notice that there is an only
one body in the design, so accessing it is an easy task, but having around 296 faces in the final model
makes it some how difficult to edit certain faces resulted from a certain feature using their index.


Thanks,

Labels (4)
2 REPLIES 2
Message 2 of 3
BrianEkins
in reply to: Moh_Samy

The problem is that the faces property of feature object returns a BRepFaces collection object not a single BRepFace object. If you change your last line of code to this it should work.

 

faces.item(0).appearance = appearanceSample1

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3
Moh_Samy
in reply to: BrianEkins

Great, it works !
Thank you very much,,

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report