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: 

Formatting Integer Numbers

1 REPLY 1
SOLVED
Reply
Message 1 of 2
isocam
124 Views, 1 Reply

Formatting Integer Numbers

Can anybody help?

 

I have the following line of code in a Python script:

 

#PartQuantity = "{}".format(len(design.rootComponent.allOccurrencesByComponent(component)))

 

At present, the output of a number, in this case the quantity in an assembly, is....

 

1---

12--

123-

1234

 

I need the numbers formatting so that the output is....

---1

--12

-123

1234

 

(The character "-" represents a space, I do not need this character in the output)

 

Can anybody update the line of code to allow me to do this?

 

Many thanks in advance!

 

Darren

1 REPLY 1
Message 2 of 2
CADacombs
in reply to: isocam

PartQuantity = "{:>4}".format(len(design.rootComponent.allOccurrencesByComponent(component)))

or

PartQuantity = "{}".format(len(design.rootComponent.allOccurrencesByComponent(component))).rjust(4)

 

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