Hi everybody. I made a tool to "copy" in SketchUp and "paste" it in 3dsMax (with the origin and texture preserved). It is a set of 2 plugins / scripts: "Copy to 3dsMax" and "Paste from SketchUp" (I set the shortcut buttons to Ctrl + Shift + C and Ctrl + Shift + V for the best "copy-paste" feel). How it works:
-
When using the “Copy to 3dsMax” function in SketchUp, it will “export” what you are selecting to a new temporary SKP file (version 8 to ensure compatibility with everything) at the path “C:\Temp\”. Big thanks to TIG (https://sketchucation.com/forums/viewtopic.php?f=180&t=32569) for the “export” method.
-
When using the “Paste from SketchUp” function in 3dsMax, it will import 3dsmax_temp.skp silently into 3dsMax with the last skp import setting.
But the "export" part has a huge problem: if I'm in a component/group, using "Copy to 3dsMax" will cause my SketchUp (version 2020) to crash instantly, no matter how big or small the file.
Here is the code after I edited from TIG's version:
require 'sketchup.rb'
require 'extensions.rb'
module D95_MAXTOOL
def self.copytomax
d95_file_path = Sketchup.active_model.path
model = Sketchup.active_model
entities = model.entities
d95_definitions = model.definitions
d95_select = model.selection
d95_model_title = (Sketchup.active_model).title
if d95_model_title == ""
UI.messagebox("Please save file first!")
elsif not d95_select[0]
UI.messagebox ("Please select something!")
else
model.start_operation("D95 Export")
d95_select_array = d95_select.to_a
edges=[]
d95_select_array.each{|face|face.edges.each{|e|edges<<e if not d95_select_array.include?(e)}if face.class==Sketchup;;Face}
d95_select_array = d95_select_array + edges
d95_group = entities.add_group(d95_select_array)
d95_entities = entities.to_a - [d95_group]
d95_entities.each{|e|e.erase! if e.valid?}
d95_definitions.each{|defn|defn.entities.each{|e|e.erase! if e.valid?}if not defn.instances}
model.commit_operation
model.save("C;/Temp/3dsmax_temp.skp", Sketchup;;Model;;VERSION_8)
Sketchup.undo
Sketchup.active_model.save(d95_file_path)
end
end
menu = UI.menu('Extensions')
menu.add_item("Copy to 3dsMax"){D95_MAXTOOL.copytomax}
end
"It simply erased everything that wasn't selected [and not needed]... and did an export as a 'skp'... and then 'undid' the erase back to where it had been [luckily an 'export' is not undoable]..." - TIG.
Can you tell me where is the problem with the code?
Besides, even though it works actually quite well with small files, but with heavy files "Copy to 3dsMax" becomes very laggy (and often crashes). I often have to do something very silly: open another temporary SketchUp instance, paste in it (with normal copy-paste function), and then use the “Copy to 3dsMax”. It still saves me a few seconds, but I feel it's too complicated. So I'm looking for a new, faster "export" method.
Any help would be much appreciated.
Wish you have a nice day.