@thomthom said:
@cjthompson said:
I thought of that, but there are still plugins that can modify a definition without having to go into edit mode.
Have you tried locking all the entities inside the definition?
How do you do that?
@thomthom said:
@cjthompson said:
I thought of that, but there are still plugins that can modify a definition without having to go into edit mode.
Have you tried locking all the entities inside the definition?
How do you do that?
Why not make it select all hidden entities? That way, he can see what is hidden, and then just press the delete key.
@cjthompson said:
assuming the plugin will always be installed?
@thomthom said:
I guess you can monitor the active entity path and close the instance when the user tries to open it..?
I thought of that, but there are still plugins that can modify a definition without having to go into edit mode.
Another idea I had was to save the component to a temp file, and then reload it, but that might be really slow. Which leads me to another question: Is there any way to load a component from a file twice? Whenever I've tried it, it doesn't create a new definition, it just ignores the command.
I am trying to find a way to lock a definition of a component, so that the end user can move an instance of it, but not modify the contents.
Is this possible, assuming the plugin will always be installed?
@tig said:
@thomthom said:
.move!
is good when you want to move without affecting the undo-stack.BUT since move! takes a transformation made in the form .new(pt) and that is no different from .new(vec) you can't move to an absolute point only a point relative to the transformation origin UNLESS you do some work beforehand to work out a .new(point) that's equivalent to an 'absolute' move ?
You need to find the origin relative to the ORIGIN ? and go from there ?
Except that .move! is essentially the same as .transformation= (as far as I understand), so all you have to do is provide an absolute point.
EDIT: that might also be the source of Martin's confusion.
I think the problem is that Transformation.new(Point3d) is the same transformation as Transformation.new(Vector3d), not the other way around. (if that makes any sense)
try this(assuming inst is a component instance):
inst.transformation = Geom;;Transformation.new([10,0,0]) #places it at 10,0,0
inst.transform!(Geom;;Transformation.new(Geom;;Vector3d.new(20,20,0)))
inst.transformation.origin # => (30,20,0), like it should
then this:
inst.transformation = Geom;;Transformation.new([10,0,0]) #places it at 10,0,0
inst.transform!(Geom;;Transformation.new(Geom;;Point3d.new(20,20,0)))
inst.transformation.origin # => (30,20,0), not (20,20,0)
Just a very small suggestion: instead of having
t = Timer.new( 1.0/fps, tt )
you might want to put:
t = Timer.new( 1/fps.to_f, tt )
That way, people experimenting with the code can easily change the numbers, without having to make sure that it's a decimal.
EDIT: Although, now that I think of it, they would only change the fps, not the 1.
@chrisglasier said:
> @dlg.add_action_callback("save_json") { |d, a|
> p = a.split(";")
> subDir = "nset/Sketchup/"
> file = File.join(File.dirname(__FILE__), subDir, p[0])
> f = File.open(file, 'w')
> f.puts p[1].to_s
> f.close
> }
>
I think the problem is
f.puts p[1].to_s
Try using
f.write p[1].to_s
Does anyone know why 4 %(space)2 works, but 4 %(no space)2 raises a syntax error (if it's in a file)?
Also, why does 2 -1 work, and 2.to_f - 1 works, but 2.to_f -1 doesn't?
this is a bit off topic, but I was just curious: how would you handle a rectangle that has a normal of (1,1,-1) or something similar?
I noticed that the API documentation for view.draw_(lines,points,etc...) mentions that it is usually implemented inside the draw method.
Is there any other way you can implement them?
I think I found what your problem is.
This works:
mesh = Geom;;PolygonMesh.new
mesh.add_polygon(Geom;;Point3d.new(0,0,0),Geom;;Point3d.new(1,0,0),Geom;;Point3d.new(1,1,0),Geom;;Point3d.new(0,1,0))
Sketchup.active_model.entities.add_faces_from_mesh(mesh)
This doesn't:
mesh = Geom;;PolygonMesh.new
mesh.add_polygon([0,0,0],[1,0,0],[1,1,0],[0,1,0])
Sketchup.active_model.entities.add_faces_from_mesh(mesh)
EDIT:
You can put the arrays inside of another array to get it to work:
mesh = Geom;;PolygonMesh.new
mesh.add_polygon([[0,0,0],[1,0,0],[1,1,0],[0,1,0]]) #this works
Sketchup.active_model.entities.add_faces_from_mesh(mesh)
now I see why it doesn't work with arrays:
mesh = Geom;;PolygonMesh.new
mesh.add_point([0,0,0])
mesh.add_point([1,0,0])
mesh.add_point([1,1,0])
mesh.add_point([0,1,0])
mesh.add_polygon([1,2,3,4])
Sketchup.active_model.entities.add_faces_from_mesh(mesh)
you can use an array to index the points directly (for some reason, starting at 1)!
Can you test whether this is faster than point_at?
@thomthom said:
PolygonMesh.add_polygon
http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/polygonmesh.html#add_polygonI can't seem to add points like the example does.
Instead, I must first add each point using
PolygonMesh.add_point
and then providePolygonMesh.add_polygon
with index values that refers to the points.
That's weird. It works just fine for me.
Have you tried vector1.angle_between(vector2.reverse)?
@al hart said:
entity.is_in_current_view - is_visible? and also is visible in current camera view
entity.is_obstructed - is visible? but is behind something else which is not transparent.
I think I would like at least these two to be part of the view object, and pass in an entity, not on the entity itself.
Here is an abridged version:
class EntityObserver
def onChangeEntity(entity)
puts entity.to_s + " changed"
end
end
$entityObserver = EntityObserver.new
def addObserver
Sketchup.active_model.selection.each{|entity| entity.add_observer($entityObserver)}
end
def removeObserver
Sketchup.active_model.selection.each{|entity| entity.remove_observer($entityObserver)}
end
If you have one entity selected, it adds and removes fine, but if you have more than one entity selected, it only removes the first entity in the selection.
Has anyone had trouble adding observers to a group of entities?
It seems to add the observers just fine, but when I try to remove them, it only is able to remove the first entity in the group. Also, if I try remove, then add any observers, it never adds the observers.
the way I solve this problem is with entities.transform_entities(entities.to_a,model.edit_transform.inverse), which effectively reset the definition.
Then, when you are done editing, just do the same thing without the .inverse
Is there any way to convert a layout drawing to a 2d dxf or dwg?