t = Geom::Transformation.scaling 2
group.transform! t
i use above code to scale s group,however the group always move far away!
I can not figure it out.
anyone helps!! thanks!
Latest posts made by YoungOSG
-
Group moves far away when i want to scale
-
RE: [Plugin] Import ALL from Folder
@tig said:
You code is overly complicated.
It also has some odd working practices...I am sure I have answered this same query elsewhere...
See the @yuyuwhy posts...
Is it you, but with a different user-name ??
http://sketchucation.com/forums/viewtopic.php?p=554042#p554042This thread explains how to setup an empty model SKP - the order of purging IS important - yours is wrong !
Do that BEFORE importing anything.It also suggests a sensible approach to the subsequent import, purge and export of each DAE in turn.
If you enclose those actions within a 'model.start_operation(...)
' block, BUT afterward each you 'model.abort_operation
' it [NOT the usual 'model.commit_operation
' it] then the imported data is simply forgotten, but the export is safe because the DAE file is now outside of the SKP's control... So there is no need to purge between each import/export at all.Recast your code thus...
Make the host SKP empty.
Process the list of DAE files in turn.
Use amodel.start_operation(...)
block around each iterate step.
Remember to use themodel.abort_operation
to undo the import etc, but leave the export intact.
You should end up with an empty SKP and all of the DAE files processed.Incidentally, your code only works in v2015 as the UI folder selector is new in that version's API.
Thanks!! I tried and it works!
And I want to import *.dae file with 2000 jpg.However Sketchup stop at 10%. It do not warn me anything.
could you help me ? -
Detecting two components and/or groups are intersected?
How to detecting two components and/or groups are intersected or not?
-
RE: [Plugin] Import ALL from Folder
@driven said:
I only use mac, but...
you could, save each file to 'Trash', close it, then open a new for the next import?
SU should then be starting fresh each time and you don't need to erase any entities?
just a thought, I use the idea in a script...
this is the an extract for Trash on a mac...def revert > trash_copy = (File.expand_path("~/.Trash/" + "." + @orig.title + ".skp")).dup.freeze > @orig.save(trash_copy) > Sketchup.send_action("closeDocument;") > Sketchup.send_action("newDocument;") > end
john
Thanks!
I tried it.It works fine on my PC,however it crashed on others. -
RE: [Plugin] Import ALL from Folder
@tig said:
You said 'ade', I guess you really meant '.DAE' ?
They should import OK.
Any error messages in the Ruby Console when try it ??Yes! I mean *.dae files.
I use your script.and add purge_unsed,export.
However i need to handle thousands of files.Sketchup always crashes after export few files.
I really don't know how to fix it.
any helps?
-
Sketchup crashes when import,purge_unused,export dae files
Sketchup crashes when import,purge_unused,export hundreds of *.dae files.
I use api to do this.It works fine while handling few *.dae files.
anyone konws why?Here is my code
require 'sketchup.rb'
require 'fileutils'UI.menu("Plugins").add_item("purge_multi_daeE") {
@import_folder = selectImportDaefolder() break if @import_folder==nil @export_folder = selectExportDaefolder() break if @export_folder==nil @daeFiles = getDaeFiles(@import_folder,".dae") purgeDaeFile(@daeFiles,@import_folder,@export_folder) Sketchup.send_action("selectSelectionTool:")
}
def purgeDaeFile(daeFiles, import_folder,export_folder)
model = Sketchup.active_modelsubName = getDirName(import_folder) Dir.chdir(export_folder) FileUtils.rm_r subName if Dir.exist?(subName) i = 0 Dir.mkdir(subName) daeFiles.each{|singleDaeFile| Sketchup::set_status_text("purge " + File.basename(singleDaeFile)) status = Sketchup.active_model.definitions.purge_unused f.puts(singleDaeFile) importDaeFile(singleDaeFile) purgeModel() resultFileName = File.join(export_folder,subName,File.basename(singleDaeFile)) Sketchup.active_model.export(resultFileName, false) deleteLastModel() }
end#def
purge dae model
def purgeModel()
# 1. purge styles
styles = Sketchup.active_model.styles
status = styles.purge_unused# 2. purge materials materials = Sketchup.active_model.materials materials.purge_unused # 3. purge definitions definitions = Sketchup.active_model.definitions status = definitions.purge_unused # 4. purge layers layers = Sketchup.active_model.layers status = layers.purge_unused
end#def
导入dae file
def importDaeFile(singleDaeFile)
model = Sketchup.active_model
model.import(singleDaeFile,false)
entities = model.entities
definitions = model.definitions
definitions.each {|definition|
transformation = Geom::Transformation.new([0,0,0])
componentinstance = entities.add_instance(definition, transformation)
}Sketchup.send_action("selectSelectionTool:")
end#def
def deleteLastModel()
model = Sketchup.active_model
entities = model.active_entities
entities.erase_entities entities.to_aend#def
-
RE: [Plugin] Import ALL from Folder
@tig said:
@mattao987 said:
...I'd like to add an optionnal STAGE in your script.
Once a file is imported, i'd like to create a new layer named by reference to the file name with a suffix.
Let's say Wonka_Niv1
Then, Group all the freshly imported items on this new layer.
Then proceed to the next file...What file type are you importing?
SKP and Others need to be treated differently...
Obviously none of this 'Layering' stuff will ever work with imported 'Images' !!For non-SKP files:
Provided there is at least one object already in the receiving-SKP, then all imported formats [other than a SKP] will already import as a component named after the file - e.g. "Wonka_Niv1.dwg".
So after line#84:
model.import(file,false)
add these lines:
unless File.extname(list[0]).downcase==".skp" ins=model.definitions[File.basename(file)].instances[0] ins.layer=model.layers.add(File.basename(file, ".*")) end#if
Note: this uses the imported files 'basename' [e.g. "Wonka_Niv1"], to use the full name with say its '.dwg. suffix use...add(File.basename(file))
insteadFor SKP imports you will need to edit another part of the code:
after line#107:
ins=model.active_entities.add_instance(defn,tr)
add this:
ins.layer=model.layers.add(name)
This uses the imported SKP's name, without any '.skp' suffix [e.g. "Wonka_Niv1"] - but if you want to add one, then change...add(name)
to...add(File.basename(file))
This should do what you want...
after i use this plugins to add ade files,i can not see them!
i can not understand why.
any helps? -
RE: I have a question, about Model.import of sketchup API
@thomthom said:
Do you get any errors?
What format are you trying to import? .skp?I import a dae file to sketchup by api. but i need to click to position. is there a way to position it automatically?
-
How to set a position for a import dae file
i used api to import dae file ,however it needs a left-click to position.
but i have many dae files , is there a way to give it a position automatically?
THANKS! -
RE: Lines won't break a face
@tig said:
If the face[s] and the rectangle that won't 'cut' are indeed coplanar select them both and "Intersect" them. they will now break... [it works I tried it... ]
if i want use sketchup api to do this,how should i do?
thanks!