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. ThanksChris
-
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!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement