Thank you very much, this is exactly what I'm looking for !
Posts made by Iltis
-
RE: Searching for a plugin code template
-
Searching for a plugin code template
Hello everyone,
I would like to "cleanly" code small extensions for SketchUp.
Is there somewhere an empty code template with best practices ? with comments that say "you have to put (this) here"
For example, I'm wondering about :
- how many folders ?
- where (folder) to put toolbar icons, what formats are supported ?
- where to put menu descriptions in the code ?
- how to separate the code into different files ?
- which "containers" to use in the code ?
I'm not a strong coder, so I'm sorry if these questions seem trivial.
Do you have anything like this to hand?
Thank you for your help,
Renaud -
RE: [Plugin] Select Curve
Hi @thomthom and folks,
I just managed to insert custom cursors to this usefull plugin.
Attached are the .png files.
The images are in the same folder than "core.rb"And this is the code :
def initialize(settings) @settings = settings folder_path = File.dirname(__FILE__) cursor_name = 'cursor_select_curve.png' cursor_select_curve_path = File.join(folder_path, cursor_name) @result = File.file?(cursor_select_curve_path) unless @result msg = "Can't find the 'cursor icon' path" UI.messagebox(msg, MB_OK) return end cursor_name = 'cursor_select_curve_plus.png' cursor_select_curve_plus_path = File.join(folder_path, cursor_name) @result = File.file?(cursor_select_curve_plus_path) unless @result msg = "Can't find the 'cursor icon' path" UI.messagebox(msg, MB_OK) return end cursor_name = 'cursor_select_curve_minus.png' cursor_select_curve_minus_path = File.join(folder_path, cursor_name) @result = File.file?(cursor_select_curve_minus_path) unless @result msg = "Can't find the 'cursor icon' path" UI.messagebox(msg, MB_OK) return end cursor_name = 'cursor_select_curve_plus_minus.png' cursor_select_curve_plus_minus_path = File.join(folder_path, cursor_name) @result = File.file?(cursor_select_curve_plus_minus_path) unless @result msg = "Can't find the 'cursor icon' path" UI.messagebox(msg, MB_OK) return end @cursor_select = UI.create_cursor(cursor_select_curve_path, 9, 5) # @cursor_select = TT;;Cursor.get_id( ;select ) @cursor_select_add = UI.create_cursor(cursor_select_curve_plus_path, 9, 5) # @cursor_select_add = TT;;Cursor.get_id( ;select_add ) @cursor_select_remove = UI.create_cursor(cursor_select_curve_minus_path, 9, 5) # @cursor_select_remove = TT;;Cursor.get_id( ;select_remove ) @cursor_select_toggle = UI.create_cursor(cursor_select_curve_plus_minus_path, 9, 5) # @cursor_select_toggle = TT;;Cursor.get_id( ;select_toggle ) @ctrl = false @shift = false end
(I'm not good in Ruby, sorry)
Hope this helps.
Renaud
-
RE: [Plugin] Select Curve
Hello @thomthom, thank you very much for this very usefull plugin.
Is there a way to add a modified cursor? (I can draw it if you tell me the specifications.)
-
RE: Triangle orientation
Thank you very much for this explanation and for the special case.
It helps a lot. -
Triangle orientation
Hello,
I'm creating faces with 3 points :
face = model.entities.add_face(pts)
Could you tell me if there is a way to know the orientation of the face according to the "direction of the rotation" between the 3 points?
Thank you very much.
Renaud. -
Invert inverted axes in symetrical components
Hello,
If the making process of a component is a duplication by symetrical operation, then "make unique", the axis are inverted.
(Sorry for this bad english! )This is a problem for me for a plugin containing arcs exportation.
Do you know how to test the orientation of the axis and how to change it temporarely in my calculations if it's not direct (red, green, blue)?
I think it must be here in my code :
# Recursively export faces and exploding groups and components def self.write_content(file, selection, tform, z) # if z==1, it's a 3D export file, if z==0, it's a 2D export file (all the Z values are equal to "0.0" and the normal.z is equal to "1.0" selection.each do |entity| if entity.is_a?(Sketchup;;Face) transform_vector_of_group(entity.normal, tform) if z == 1 || (z == 0 && transform_vector_of_group(entity.normal, tform).parallel?(Z_AXIS) && transform_point_of_group(entity.vertices[0].position, tform).z.abs < 0.001 ) # Sketchup tolerance ; 0.0001 inch $number_of_exported_faces +=1 write_face(file, entity, tform, z) result = Sketchup.set_status_text $number_of_exported_faces.to_s, SB_VCB_VALUE end elsif entity.is_a?(Sketchup;;Group) || entity.is_a?(Sketchup;;ComponentInstance) if entity.is_a?(Sketchup;;Group) definition = entity.entities.parent else definition = entity.definition end write_content(file, definition.entities, tform * entity.transformation, z) end end end
Thank you very much.
Renaud. -
RE: How detect that a file is locked by another app?
Thank you very much for these complementary solutions.
Renaud.
-
RE: How detect that a file is locked by another app?
TIG, your solution is working fine. Thank you very much.
@jim said:
Did you try something like File.writable?("file")?
Yes Jim, not working.
BR,
Renaud. -
RE: How detect that a file is locked by another app?
OK, will try it. Thank you!
-
RE: How detect that a file is locked by another app?
Hello driven,
Thank you for your answer, but I think it's not what I need.
In my case, in the real code (not my example here), the export is in a .dxf file. To test the quality/errors of the export, the .dxf file is open in a CAD software. Then, if I try in SU to overwrite the file with my plugin (after some modification in the SU model for example), and if the file is already opened in the CAD software, the file is locked by the CAD software. If I make this with a .txt file opened in Notepad++, there is no problem, because Notepad is not locking the file (and will detect the change!).
I want to track the error and say to the user to close the file in the CAD software or to rename the file.(I'm french, sorry for my writting mistakes.)
Renaud. -
How detect that a file is locked by another app?
Hello,
After more than one hour of research, I already don't know how to catch the error when I export a file already opened by another application.
out_name = UI.savepanel('Location', '' , "#{File.basename(model.path).split(".")[0]}.txt") if out_name if File.extname(out_name).downcase != ".txt" # if the user erase the extension, rewrite it! out_name += ".txt" end file = File.new(out_name , 'w') file.puts(%Q["blabla"]) file.close() end
@unknownuser said:
Error: #<Errno::EACCES: Permission denied - C:\test\test3.txt>
Could you help me? I wanted to send a message to the user (and maybe to propose to increase an index at the end of the file's name).
Best regards,
Renaud. -
RE: [solved]Syntax problem with a Sketchup::Face
OK, it's a typo! entitiy instead of entity! Shame on me!
-
[solved]Syntax problem with a Sketchup::Face
Hello,
Could you tell me what's wrong in this code?
(Z is a parameter. If z=0, I want only the faces in the Z=0 plane)selection.each do |entity| if entity.is_a?(Sketchup;;Face) if z == 1 || (z == 0 && entity.normal.x.abs < 0.00001 && entitiy.normal.y.abs < 0.00001 && entity.vertices[0].z.abs < 0.000001 ) # Sketchup tolerance ; 0.0001 inch) ........
In the Ruby console :
Error: #<NameError: undefined local variable or method `entitiy'Thank you for your help.
BR,
Renaud. -
RE: [plugin]Export arcs, circles and vertex to dxf ?
I just saw that the .xaxis propery of the arcs are rotated => start_angle=0 is right, because the reference is wrong. OK, knowing that, I can see how to do this.
-
RE: [plugin]Export arcs, circles and vertex to dxf ?
Hello TIG,
Like other people, I have the following problem : with the(Sketchup::ArcCurve)
entities, the arcs are always rotated, with the.start_angle
value equal to 0.0 (and not equal to the angle with the X axe, the API documentation is wrong on this point in my situation - working with the entities of the loops).
Do you have a clean (and 3D) workaround?
Best regards,
Renaud. -
RE: [plugin]Export arcs, circles and vertex to dxf ?
Thanks TIG, I will work on it.
-
List of entities and organisation ?
Hello,
Do you know if there is a schematic/list of the SketchUp geometrical entities and of their relationships?
For example : ArcCurve (arcs and circles) is a subclass of the Curve class, and an edge is a part of a random curve if
edge.curve
return a curve, and a part of an arccurve ifedge.curve
return an arccurve.Best regards,
Renaud. -
RE: [plugin]Export arcs, circles and vertex to dxf ?
Hi,
In fact, there is the problem of the order of the vertices to make the polylines. I think I must follow the loops, like in the initial code of guitar-list, but I must test the ".curve" of each vertex and extract the arcs, circles, and the polylines with vertices in the order. A little tricky for me, I will take a paper and a pencil!