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: 

Conversion of a simple Inventor VBA macro to Python

1 REPLY 1
Reply
Message 1 of 2
isocam
210 Views, 1 Reply

Conversion of a simple Inventor VBA macro to Python

Can anybody help?

 

I have the following Inventor VBA macro:

 

Quantity = "12"

PartDescription = "TEST PART DESCRIPTION"

OutputString = OutputString & Space(22 - Len(OutputString)) & Space(4 - Len(Quantity)) & Quantity

OutputString = OutputString & Space(28 - Len(OutputString)) & PartDescription

OutputString = OutputString & Space(188 - Len(OutputString)) & "P" & " " & "T"

 

Can anybody convert the script to Python?

 

Many thanks in advance!

 

Darren

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

Hi @isocam ,

 

Here is the python code for it:

 

OutputString = "..."  #set initial value
Quantity = "12"
PartDescription = "TEST PART DESCRIPTION"
# OutputString = OutputString & Space(22 - Len(OutputString)) & Space(4 - Len(Quantity)) & Quantity
OutputString = f'{OutputString:22.22}{Quantity:4.4}'
# OutputString = OutputString & Space(28 - Len(OutputString)) & PartDescription
OutputString = f'{OutputString:28.28}{PartDescription}'
# OutputString = OutputString & Space(188 - Len(OutputString)) & "P" & " " & "T"
OutputString = f'{OutputString:188.188}P T'

print('         1         2         3         4         5         6         7         8         9        10'
      '        11        12        13        14        15        16        17        18        19        20')
print('....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0'
      '....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0')
print(OutputString)

 

 

Hope it helps.

 

Regards,

Jorge Jaramillo

 

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

Post to forums