send_to_layout or Layout::Document.open(filename)

send_to_layout or Layout::Document.open(filename)

Postby sjn001tvh » Wed Jan 23, 2019 2:32 am

Hi,

I seemed to have hit another road block. This time in terms of trying to use the send_to_layout method within Sketchup.

My objective is as follows:
1. create a routine that creates a copy of any of the selected assembly to a single component
2. save that component to a file
3. open the file and separate each component so that it is viewed from a side view
4. space them apart within a Scene based on predefined margins
5. send each Scene to a Layout file, each Layout Page/Sketchup Scene
6. then manipulate the Layout tools to attach the dimensions to each object

But I can't seem to get past getting Sketchup to create a new Layout file.

Using the console here's what happens. I created the directory and made sure it existed.

x_layoutDir = x_dirPath + "/" + "LayoutSets"
Dir.exist?(x_layoutDir)
true


Then used send_to_layout to create a new Layout file.

x_result = Sketchup.send_to_layout(x_layoutDir + "/MyTestLayoutFile.layout")
false


No luck. Found another command and tried it.

objLayout = Layout::Document.open(x_layoutDir + "/MyTestLayoutFile.layout")
Error: #<ArgumentError: File does not exist>
<main>:in `open'
<main>:in `<main>'
SketchUp:1:in `eval'


No Luck. Found another option by just using the send_action.

Sketchup::send_action("sendToLayOut:")
false


Again no luck. So, I tried this from another angle. I first created the file.

objLayout = Layout::Document.open(x_layoutDir + "/MyTestLayoutFile.layout")
#<Layout::Document:0x0002751b936538>


Success!!!

However, it was somewhat short lived, because I couldn't view the file from Layout that I had just opened. And even though it appeared to be successful I couldn't get Layout to open so that I can view the results of using the methods.

Plus, it brought up another question. Is there a way to have Sketchup create and open the Layout file, without having to have a file already existing?

I tried...
objLayout = Layout::Document.new(x_layoutDir + "/MyNewLayoutFile.layout")
Error: #<ArgumentError: The template file could not be found>
<main>:in `initialize'
<main>:in `new'
<main>:in `<main>'
SketchUp:1:in `eval'


I couldn't find where I could implement Layout template file and when I created a Layout template file, there wasn't any type of method that would allow me to create new file using it.

So, I would like to have 2 questions answered.
1. How do I get Sketchup to create a new Layout file?

2. Is there a method to open the Layout application and view the document that was just opened using the Layout::Document.open method?

Thanks,
Scott.
0

sjn001tvh 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 


 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 10 guests

Visit our sponsors: