• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Passing coordinates javascript to callback

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 365 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    chrisglasier
    last edited by 5 Jun 2008, 06:01

    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

    With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

    1 Reply Last reply Reply Quote 0
    • A Offline
      azuby
      last edited by 5 Jun 2008, 07:38

      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

      *error initus :: Blocks | CurrentDate | d/Code | extensionmanager | FFlipper | HideEdges | MeasuredArea | ModelHistory | PluginsHelp | PronButton | SAWSO | SCP | SU²CATT

      Bad English? PM me, correct me. :smile:**

      1 Reply Last reply Reply Quote 0
      • C Offline
        chrisglasier
        last edited by 5 Jun 2008, 08:43

        Integer(a[3] ...) works just fine. Many thanks!

        With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement