Code Monkey home page Code Monkey logo

liveparametric's People

Contributors

etjones avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

liveparametric's Issues

a 2nd method call within create_entities with 'container' as argument crashes LiveParametric

a 2nd method call within create_entities with 'container' as argument crashes LiveParametric.

The error message is :-

Error: #<TypeError: reference to deleted Entity>
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/ETJ/LiveParametric/parametric.rb:111:in attribute_dictionary' C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/ETJ/LiveParametric/parametric.rb:111:inattribute_dictionary'
C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/ETJ/LiveParametric/parametric.rb:170:in set_attributes' C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/ETJ/LiveParametric/liveParametric.rb:102:inlaunchWebDialog'

some how the `attribute_dictionary' entity gets deleted?

I can let you have the code by email or maybe I can create a repository here in github - I'm absolutely new to github.

DropdownList strings containing HTML chars are ignored

Bug description

If HTML characters (angle brackets, etc.) are sent to a DropdownList (or other VariableDicts, probably) the bracketed parts will be ignored.

A solution would be to use cgi.escapeHTML to escape all LP strings, but cgi isn't included in SU's Ruby. Will investigate an alternative solution.

Workaround

Er, for the moment don't use strings with angle brackets in them.

Demo program:

class DropdownBugExample < LiveParametric
# Correct behavior would yield a dropdown list with these entries:
# good element
# missing word
#
# Actual behavior yields:
# good element
# missing word
def default_variables
possible_vals = ["good element", "missing word"]
[ DropdownList.new("test_dropdown", possible_vals)]
end
def create_entities( data, container)
container.add_face( [[0,0,0],[0,1,0],[1,0,0]])
end
end

Components and LiveParametric

Evan,
Thanks for your most recent reply. There is one issue you could maybe advise me on.
I'm having difficulty converting my LiveParametric objects into a component instance within the script.
Here are 2 short programs which show my problem. The non-component version works fine except I need to convert it to a component ( like a window or door would be). The component version produces an insert-able component but can't be edited. In a nutshell, how do I write the script so that I get an editable parametric component. The code in testy1.rb is based on windows.rb which ships as an example program with SketchUp.

class Testy2 < LiveParametric

This script does not make a component but LiveParametric works.

@@decideWhichStr = "Pick a Number"

def default_variables       
    [   
    DropdownList.new( @@decideWhichStr,["1","2"],"1")
    ]
end

def create_entities( data, container)

    decideWhich = data[@@decideWhichStr]
    decideWhich = decideWhich.to_i
    puts decideWhich

    case(decideWhich)
        when 1
            puts("decideWhich is 1")
            Testy2.drawBlocks1(container)
        when 2
            puts("decideWhich is 2")
            Testy2.drawBlocks2(container)
    end
end

def Testy2.drawBlocks1(container)
        d = 100.cm
        h = 100.cm
        w = 100.cm
        g = container.add_group

        f = g.entities.add_face([0,0,0], [w,0,0], [w,d,0], [0,d,0])
        f.pushpull(-h)

end

def Testy2.drawBlocks2(container)
        d = 100.cm
        h = 100.cm
        w = 100.cm
        g = container.add_group

        f = g.entities.add_face([0,0,0], [w,0,0], [w,d,0], [0,d,0])
        f.pushpull(h)

end


def Testy2.create
    testy2 = Testy2.new
end

end

And the next script is :-

class Testy1 < LiveParametric

This script makes a component but LiveParametric does not work.

def class_of_object
    Sketchup::ComponentInstance
end
def create_entity(model)
    #TODO: try to find existing definition matching the parameters
    @entity = model.definitions.add self.compute_name

    # Set the behavior
    behavior = @entity.behavior
    behavior.is2d = true
    behavior.snapto = 0
    behavior.cuts_opening = true
    @entity
end

@@decideWhichStr = "Pick a Number"

def default_variables       
    [   
    DropdownList.new( @@decideWhichStr,["1","2"],"1")
    ]
end

def create_entities( data, container)

    decideWhich = data[@@decideWhichStr]
    decideWhich = decideWhich.to_i
    puts decideWhich

    case(decideWhich)
        when 1
            puts("decideWhich is 1")
            Testy1.drawBlocks1(container)
        when 2
            puts("decideWhich is 2")
            Testy1.drawBlocks2(container)
    end
end

def Testy1.drawBlocks1(container)
        d = 100.cm
        h = 100.cm
        w = 100.cm
        g = container.add_group

        f = g.entities.add_face([0,0,0], [w,0,0], [w,d,0], [0,d,0])
        f.pushpull(-h)

end

def Testy1.drawBlocks2(container)
        d = 100.cm
        h = 100.cm
        w = 100.cm
        g = container.add_group

        f = g.entities.add_face([0,0,0], [w,0,0], [w,d,0], [0,d,0])
        f.pushpull(h)

end


def Testy1.create
    testy1 = Testy1.new
    definition = testy1.entity
    Sketchup.active_model.place_component definition, true
end

end

Thanks for any help you can give me with this.

Francis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.