Hello All,
Sorry for the daft questions!
I’m trying to create a script to read a csv and import SKPs and place them by their origin to a given point.
When the skp is imported it is ‘stuck’ to the mouse pointer.
How do I import to a point?
here is my code
def ak_PandP
# Vars for model
mod = Sketchup.active_model
ents = mod.active_entities
pcbview = Sketchup.active_model.active_view
# generate an open file dialog and store location in 'dxfLocation'
csvLocation=UI.openpanel("Import Placement CSV", "", "CSV|*.csv||")
if csvLocation == nil
puts "cancelled at CSV in!"
else
#Generate user input box to get pcb thickness store in pcbInput array
#akPrompts store name for imputbox array
akPrompts = ["PCB Thickness"]
#akDefaults store default value array .mm to give dimension to the array element
akDefaults = ['1.6.mm'.to_l]
pcbInput = UI.inputbox(akPrompts,akDefaults,"PCB Thickness")
#Take array element and store in var 'pcbThickness'
if pcbInput == false
puts "cancelled at Thickness!"
else
pcbThickness = pcbInput.at(0)
IO.foreach(csvLocation){|block|
lineArray=block.split(",")
point = [10,10,0]#i will add point from csv later
puts lineArray
puts block
mod.import "C:/Users/me/Desktop/DemoPCB/SupportingDocs/" + lineArray.at(1)
importSkp=mod.selection
importSkp.move! point
UI.messagebox("pause")
}
pcbview.zoom_extents
puts "Done, you can now close the Ruby Console "
end
end
end
Thanks Ed