thanks, I am relying on you now
i m not sure if this is possible to import?
i copy’d packer from rectpack into the same location as decimal (which i’ve used before) as you can see decimal doesnt give any errors, packer does.
i m not sure what to do now. Maybe someone more experienced can help?
Thank you @Schasfoortyoeri, I appreciate you taking the time to make it work. But as you said will wait and see if someone can provide us with the right solution?
I copied the folder rectpack in the IronPython2.7 folder and it seems to work.
Also you probably need to write a r before your path:
import sys sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
Another way if you want to copy the rectpack folder into a given directory:
import clr import sys sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib') import os os.system('python C:\rectpack-master\rectpack.py') from rectpack import newPacker rectangles = [(100, 30), (40, 60), (30, 30),(70, 70), (100, 50), (30, 30)] bins = [(300, 450), (80, 40), (200, 150)] packer = newPacker() #Add the rectangles to packing queue for r in rectangles: packer.add_rect(*r) #Add the bins where the rectangles will be placed for b in bins: packer.add_bin(*b) #Start packing packer.pack() nbins = len(packer) OUT= nbins
Edit: It does not work in this case.
could you explain why to write the r before the path? just out of curiosity
r is used to indicate a raw string.
Since the backslash is used to escape characters that otherwise have a special function, putting r before the string indicates to read the backslash as backslash and not as escape command.
Some more info here:
Things seem to work now. Thank you @lucamanzoni
what does this line do?
and how did you get rectpack-master folder with rectpack.py init?
I couldn’t find rectpack.py anywhere
You’re right, there is no rectpack.py file so it can’t load the file.
I missed something in my test.
The best way is to copy the folder in C:\Program Files (x86)\IronPython 2.7\Lib to load the module.
Does os.system(‘python C:\rectpack-master\rectpack.py’) mean you can python shell command?
can you please explain it I am curious to know more about the line that you used?
Here is a successful example:
Very interesting idea to run the script. Thanks @Alban_de_Chasteigner
Is this being used to stack views on a sheet? Would be amazing to have rectangles (viewport length and width) in as a list with the script. Then an in for the bin (sheet). But then would need an output of the center point of the stacked rectangles. Could then use that information to put views on the sheet. Another obstacle is to output views that didn’t fit to go on another sheet. I don’t have the skills at python to achieve this but thought I’d put it out there if anyone’s keen to try
Yeah, it’s possible
This may also be relevant: https://bit.ly/2DPdriQ
That said we’re getting off topic, if we’d like to continue I can split out relevant posts (or someone start a new topic and link back as needed).
The holy grail! Would you be kind enough to share?
I’ve been waiting for Thomas Corrie to finish his package but its been some time
Any idea how to format things correctly to change it to taking a list? spent a few hours. Cannot figure out the arguments. Went from 27 down to 2 but need 3 or max 4. Been reading to try understand. Seems like I need “self” infront but I just don’t quite get it haha
I always get 1 if I do this but no errors which so I’m not really sure if I’ve done the library correct
Side question. Could you copy code from rectpac into dynamo python script instead of installing the library?
it might be what you seek
Thanks Saeedy. I’ve used that but I’m really after something that works out where to place the views. Need the bin packing algorithm sorted to get the coordinates of where to place views to use that script from the link.