Send_to_layout or Layout::Document.open(filename)
-
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:
- create a routine that creates a copy of any of the selected assembly to a single component
- save that component to a file
- open the file and separate each component so that it is viewed from a side view
- space them apart within a Scene based on predefined margins
- send each Scene to a Layout file, each Layout Page/Sketchup Scene
- 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>:innew' <main>:in
<main>'
SketchUp:1:ineval'
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.
-
How do I get Sketchup to create a new Layout file?
-
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.
Advertisement