Skip to content
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

Merged
merged 16 commits into from
Jan 25, 2017

Conversation

jimfoltz
Copy link
Contributor

@jimfoltz jimfoltz commented Jan 7, 2017

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.

@write_face = method(:write_face_ascii)
end
scale = scale_factor(options['export_units'])
write_header(file, model_name(), options['stl_format'])
Copy link
Member

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()

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 'current' redundant?

Copy link
Contributor Author

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.

Copy link
Member

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()
Copy link
Member

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
Copy link
Member

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" +
Copy link
Member

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'
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

@thomthom thomthom Jan 16, 2017

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

@thomthom thomthom merged commit ef3e6e2 into SketchUp:master Jan 25, 2017
@jimfoltz jimfoltz deleted the hotfix/empty_export_warning branch January 25, 2017 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants