When you make an entire novel out of it and then ask me to represent it to a publisher.
I just received a query from someone wanting to write a novel set in the world of a very popular science fiction franchise, one that currently enjoys a booming (and legit) business through a major New York publisher by licensing that publisher the rights to use the characters and world. (No, it was not a Star Wars novel, but you're getting warm. Think another long-running series that begins with the letter S and has about a billion books associated with it. Also, bald captain. Thinking...Thinking... Ha! Got it? Good.)
Here's a piece of advice for you would-be-writers: Do not EVER - under any circumstances - send an agent a query for a novel based on someone else's characters or world. Just don't.