Passing coordinates javascript to callback
-
I can pass the project, subDir and file variables from this Javascript array and function
//test components
SUData = new Array()
SUData.push(new Array("Sanitaryware","P_toilet",100,100,100))
SUData.push(new Array("Sanitaryware","Sink_Counter_Triple",200,200,200))
SUData.push(new Array("Sanitaryware","Bathtub_60x32",300,300,300))
SUData.push(new Array("Sanitaryware","Shower_4x6",400,400,400))function setModel(){
project = "NamesetComponents"for(a=0; a<SUData.length; a++){
SUData[a].splice(0,0,project)
para = SUData[a].join(",")
window.location = 'skp:find@'+para }
//startSetUp()
}to this callback
@dlg.add_action_callback("find") {|d, p|
a= p.split(",")
subDir = a[0]+"/"+a[1]+"/"
fileName = a[2]+".skp"
theX = a[3]
theY= a[4]
theZ = a[5]point = Geom::Point3d.new(theX,theY,theZ) transform = Geom::Transformation.new point model = Sketchup.active_model entities = model.active_entities path = Sketchup.find_support_file fileName, subDir definitions = model.definitions componentdefinition = definitions.load path instance = entities.add_instance componentdefinition, transform } but I cannot get the X, Y, Zs to work. Without them the entities settle nicely at 0,0,0. I am very new at this, so if there's an obvious answer I apologise but would be grateful to have it. Thanks
Chris
-
Maybe you need to convert them (theX, ...Y, ...) to Fixnum/Integer. If you're sure they really are digits, you can use String#to_i, else you should use Integer() (i.e.: Integer(a[2])) and catch exceptions.
azuby
-
Integer(a[3] ...) works just fine. Many thanks!
Advertisement