etjones / liveparametric Goto Github PK
View Code? Open in Web Editor NEWExtension to Google Sketchup's Parametric class example to allow live updating & richer UI.
Extension to Google Sketchup's Parametric class example to allow live updating & richer UI.
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:in
attribute_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:in
launchWebDialog'
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.
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.
Er, for the moment don't use strings with angle brackets in them.
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
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
@@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
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
imported from old Google code repo
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.