TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Kerry on October 05, 2005, 02:25:29 AM
-
[Specifications] Layer Set Function.
1: }
2: }
3: }
4: }
5: }
6: }
7: }
8: }
9: }
10: }
11: }
12: }
13: }
?? What are the specifications .
PS : No Code Please untill the specifications are agreed upon.
[added]
[Specifications] Layer Set Function.
Possible Parameters :
- Layer Name
- Required Properties
- Required Status
- Other ??
Assertions :
- Determine if the layer exist .. Make if not < either use properties or defaults >.
- Determine if usable .. Do we change it ??
- Other ??
Associated Assertions :
- Linetype < file depends on units ; scale ; >
- Other ??
Actions:
- Set Status
- Set Properties ??
- Other ??
Return :
Layer ObjectID or NIL
Unresolved Design querys :
- If Layer is changed, Do we save the name of current layer From this module or from caller ?
- If properties are changed, do we save the current for restoration( and; from this module or from caller > ?
- What level of error trapping is required ?
- Other ??
Do we work to these 2 scenarios
Either :
- Just check the layer exists ; say we are using CHPROP or functionality that requires the layer..
- Force the layer to be current ; say we want to draw onto it.
- Other ??
.. any others ??
[/added]
[update] to suit input [/update]
-
I am a firm believer that most code writes itself if the specifications and then pseudocode are written properly.
As with all problem solving, the quality of the question in part determines the quality of the answer.
Please note that the title is NOT a true description of the brief. Layer Set Function could mean anything <well, almost>
It would be nice if there was also some input from other than the usual suspects .. :)
-
[Specifications] Layer Set Function.
1: Determine if the layer exist
2: if it exist then thaw, unlock, turn on, set current
3: if it does not exist MAKE it, options are name, color, linetype
4: make sure the options are valid or catch the error
{good morning} :-)
-
Addendum: Add a flag to indicate whether the proposed layer name must pass (snvalid layername 0|1) test(s).
-
To begin with I believe it is imperitive to determine if the layer exists, then you can verify whether or not the layer is locked, off, or frozen (a locked, off or frozen current layer is not a good thing). That being said, if this is going to be a true "layer set function", we probably don't need to create the layer if it does not exist, rather it should return the current layer if it exists or nil if it does not.
I suggest a wrapper function for activex as well, thus the set layer command could be used in both plain lisp and vlisp.
Now perhaps I may be looking too deeply into the function, but aside from the regular "set layer" functionality (if that is indeed the purpose) why not have the ability to set the properties of the layer, those properties being ... current, color, name, linetype, lineweight, plot, noplot, lock, unlock, freeze, thaw, on, off. i.e. (LayerSet "somelayer" "current" nil) or (LayerSet "somelayer" "name" "differentname")
It just occured to me that we could use constants to define the differing states ...
vlCurrent
vlName
vlPlot
etc ....
-
For LayerSet calling function:
1: ...
2: ...
n: Record current layer
n+1: Call LayerSet
n+2: If LayerSet then add current layer to history
n+3: Provide LayerSetPrevious(history) option
n+4: ...
-
Uhh... Yea... What they said. :-)
-
... title is NOT a true description of the brief. Layer Set Function could mean anything <well, almost>
-
I am a firm believer that most code writes itself if the specifications and then pseudocode are written properly.
I must admit, I never had followed any pseudocode.... :-(
-
Hi Louis, you probably do yours in your head, just sitting down quietly and thinking through a problem and making notes is a form of code design.
-
Don't forget to check VP layer status...
-
.. and the description...
-
... title is NOT a true description of the brief. Layer Set Function could mean anything <well, almost>
In it's basest form,- check for layer
- If exists, set layer to current
- Else, do nothing
- Get out
If it is essential that the layer exist and be set then base- check for layer
- If not exists, make layer
- set layer
- Get out
Optimally if the end result is to have a specific layer with the current properties needs to be set current- check for layer
- If not exists, make layer,set all required properties of layer
- set layer
- Get out
It could be much, much different depending on what actually is desired/required.
-
It could be much, much different depending on what actually is desired/required.
The idea of the thread is to find out what people think IS required from a routine like this. If YOU were contracting to have the code written what would you want the routine to do ? explicitly. not HOW just WHAT.
-
I guess then that if I were contracting I would want the third option I listed along with additional functions to
a) get current layer state
b) reset to layer state obtained with 'a'
-
Refer to the original post for Updates :
Any more comments ??