-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix/empty export warning #165
Hotfix/empty export warning #165
Conversation
@write_face = method(:write_face_ascii) | ||
end | ||
scale = scale_factor(options['export_units']) | ||
write_header(file, model_name(), options['stl_format']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style guide says to not use parentheses for method calls with no arguments; model_name()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know - I just never liked the way a name in Ruby could either be a variable or method. WIll comply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you mean. Though it appear all Ruby style guides disagree, so do the IDE linters. Better to just follow the main stream.
@@ -230,6 +225,27 @@ def self.get_vertex_order(positions, face_normal) | |||
order | |||
end | |||
|
|||
# Return model.active_entites, selection, or nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use YARD style comments for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe? That would be the only YARD style comment in the entire source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was just a question though. You can leave this as-is if you want.
else | ||
export_ents = Sketchup.active_model.active_entities | ||
end | ||
return export_ents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style guide says to not use return
unless returning early - instead rely on the implicit return.
msg = "SketchUp STL Exporter:\n\n" | ||
msg << "You have chosen \"Export only current selection\", but nothing is selected." | ||
msg << "\n\nWould you like to export the entire model?" | ||
if UI.messagebox(msg, MB_YESNO) == IDYES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this warning only appear if the user set the export options to Selection with no selection made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. How much hand-holding is the right amount? Again, I based this on the Pro exporters opting for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am more concerned about keeping message boxes to a minimum than the hand-holding. This is fine as it's an edge-case that the user should not run into often.
@@ -261,7 +277,7 @@ def self.do_options | |||
|
|||
# Row 1 Export Selected | |||
chk_selection = SKUI::Checkbox.new( | |||
'Export selected geometry only.', | |||
'Export only current selection', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 'current' redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the text from the other Pro exporters - I know that doesn't necessarily make it right but it is consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, then lets keep in consistent.
control.window.close | ||
export_entities = get_export_entities() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: not empty parentheses with empty method calls.
path = select_export_file() | ||
begin | ||
export(path, export_entities, OPTIONS) unless path.nil? | ||
rescue => exc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style guide says to prefer full names over abbreviations. exc
would be better expanded to exception
if that was what you meant. However, default catch is StandardError
in this case.
# show the export dialog. | ||
def self.main | ||
if Sketchup.active_model.active_entities.length == 0 | ||
msg = "SketchUp STL Exporter:\n\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style guide says to avoid + to concat strings. I think <<
is preferred over +
, but I also think you can do something like this in Ruby:
str = "Hello"\
"World"
@@ -52,7 +52,7 @@ def self.translate(string) | |||
'This is an open source project sponsored by the SketchUp team. More ' << | |||
'info and updates at https://github.com/SketchUp/sketchup-stl' | |||
) | |||
extension.version = '2.1.6' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this bumped from 2.1.6 to 2.1.8? What about 2.1.7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the normal fix was going to be 2.1.7 but maybe I didn't push the tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - I see. I don't think we published that. So on EW it's still 2.1.6. Can you make a new commit with version set to 2.1.7? Then I'm squash-merge this and get it uploaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I've tagged the commit in my repo but not sure what to do now. Just need to tag commit #fefa9098be9600efb5ac7e49ef52777cc973fe76 with v2.1.7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tags in your repo doesn't follow the Pull Request - I think. The tag is something I have to set in order for it to apply to this repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't matter for me. We usually end up with a couple of commits after a PR is done anyway - in which case we squash everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes can help follow the thought process better - that's the main reason I might prefer to keep them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean in the master branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean in the master branch?
No, but in the dvelopment branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that's perfectly fine and I think it's a common git workflow.
Fixes #159
The STL Exporter would happily export a .stl file with no facets if the "Export selection only" option was checked but nothing in the model was actually selected.