Staircase macro deluxe
Hello-
I decided to take the staircase macro that is mentioned in the tome of mapping and modify it a little. To wit, I wanted to have the reference line deleted when the macro was done. At first I thought this should be easy, just erase the entity. But the problem seems to be that whatever point I choose to select the reference entity is also a point that one of the "step" lines goes through, so both the reference line and the step line get erased. Digging into the macro a little, I thought if I choose a point on the reference line that is not near the points selected for drawing the steps, that should allow me to do a get entity using the new point and nothing should be deleted. Well this works fine for horizontal and vertical reference lines, but anything at an angle, the reference line is deleted, but the first one or two step lines are also deleted. And I can't for the life of me figure out why. I have experimented with values of 0.1 to 1.5 and 0.5 gets the best results.
MACRO STAIRCASE
ECOFF
SELSAVE
LWIDTH 0;LSTYLE solid;FSTYLE solid
GV varStepWidth 10
GV varStepWidth ^DEnter the stairway width [10]:
GV varStepDepth 1
GV varStepDepth ^DEnter the step spacing [1]:
GE varEntity ^DSelect object to draw the staircase along:
IFERR MacroDone
GLEN varEntityLen varEntity
GN varStepNum varEntityLen/varStepDepth
GV varUnit 100/varStepNum
GV varCurStep 0
GP varEntPoint % (varUnit*.5) varEntity <--Here I get a point on the reference entity that shouldn't be a "step" line as well
GP varP1 % 0 varEntity
GBRNG varB1 varP1 % .01 varEntity
LINE ref varP1 <varB1+90,(varStepWidth/2) ref varP1 <varB1-90,(varStepWidth/2);
:Loop
GV varCurStep varCurStep+1
GP varP1 % (varCurStep*varUnit) varEntity
GBRNG varB1 varP1 % (varCurStep*varUnit)-.01 varEntity
LINE ref varP1 <varB1-90,(varStepWidth/2) ref varP1 <varB1+90,(varStepWidth/2);
IFP varStepNum-varCurStep Loop
SELBYP
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1+90,1
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1-90,1
SELBY1
GE varEntDel varEntPoint <-- Here I "reselect" the reference entity but at a new point on the line
SELBY1
ERASE varEntDel <-- Here I erase the entity
REDRAW
:MacroDone
SELREST
ECON
ENDM
As I said, this works fine for horizontal and vertical reference lines, but any line other than those...
Pete the Perplexed
I decided to take the staircase macro that is mentioned in the tome of mapping and modify it a little. To wit, I wanted to have the reference line deleted when the macro was done. At first I thought this should be easy, just erase the entity. But the problem seems to be that whatever point I choose to select the reference entity is also a point that one of the "step" lines goes through, so both the reference line and the step line get erased. Digging into the macro a little, I thought if I choose a point on the reference line that is not near the points selected for drawing the steps, that should allow me to do a get entity using the new point and nothing should be deleted. Well this works fine for horizontal and vertical reference lines, but anything at an angle, the reference line is deleted, but the first one or two step lines are also deleted. And I can't for the life of me figure out why. I have experimented with values of 0.1 to 1.5 and 0.5 gets the best results.
MACRO STAIRCASE
ECOFF
SELSAVE
LWIDTH 0;LSTYLE solid;FSTYLE solid
GV varStepWidth 10
GV varStepWidth ^DEnter the stairway width [10]:
GV varStepDepth 1
GV varStepDepth ^DEnter the step spacing [1]:
GE varEntity ^DSelect object to draw the staircase along:
IFERR MacroDone
GLEN varEntityLen varEntity
GN varStepNum varEntityLen/varStepDepth
GV varUnit 100/varStepNum
GV varCurStep 0
GP varEntPoint % (varUnit*.5) varEntity <--Here I get a point on the reference entity that shouldn't be a "step" line as well
GP varP1 % 0 varEntity
GBRNG varB1 varP1 % .01 varEntity
LINE ref varP1 <varB1+90,(varStepWidth/2) ref varP1 <varB1-90,(varStepWidth/2);
:Loop
GV varCurStep varCurStep+1
GP varP1 % (varCurStep*varUnit) varEntity
GBRNG varB1 varP1 % (varCurStep*varUnit)-.01 varEntity
LINE ref varP1 <varB1-90,(varStepWidth/2) ref varP1 <varB1+90,(varStepWidth/2);
IFP varStepNum-varCurStep Loop
SELBYP
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1+90,1
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1-90,1
SELBY1
GE varEntDel varEntPoint <-- Here I "reselect" the reference entity but at a new point on the line
SELBY1
ERASE varEntDel <-- Here I erase the entity
REDRAW
:MacroDone
SELREST
ECON
ENDM
As I said, this works fine for horizontal and vertical reference lines, but any line other than those...
Pete the Perplexed
Comments
To circumvent what you experience, I used the following steps:
1. Move the entity to erase to a specific Layer created just for that immediately after selection (and prior to any addition)
2. Once the drawing is over, make the new layer active
3. Hide all other layers
4. Erase All
5. Show all the layers again
The drawback is that if you had any hidden layer before using the macro, it will show at the end. I'll gladly welcome any better solution...
You will find a more detailed version here in the Tutorial #1 pages 15+.
MACRO STAIRCASE
ECOFF
RDOFF
SELSAVE
POINT 10001,10001;
LWIDTH 0;LSTYLE solid;FSTYLE solid
GV varStepWidth 10
GV varStepWidth ^DEnter the stairway width [10]:
GV varStepDepth 1
GV varStepDepth ^DEnter the step spacing [1]:
GE varEntity ^DSelect the reference entity to draw the staircase along:
IFERR MacroDone
SELBY1
GOLAYER ToErase
CHANGEL varEntity ToErase
SELBY1
GOLAYER MacroConstruct
GLEN varEntityLen varEntity
GN varStepNum varEntityLen/varStepDepth
GV varUnit 100/varStepNum
GV varCurStep 0
GP varP1 % 0 varEntity
GBRNG varB1 varP1 % .01 varEntity
LINE ref varP1 <varB1+90,(varStepWidth/2) ref varP1 <varB1-90,(varStepWidth/2);
:Loop
GV varCurStep varCurStep+1
GP varP1 % (varCurStep*varUnit) varEntity
GBRNG varB1 varP1 % (varCurStep*varUnit)-.01 varEntity
LINE ref varP1 <varB1-90,(varStepWidth/2) ref varP1 <varB1+90,(varStepWidth/2);
IFP varStepNum-varCurStep Loop
SELBYP
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1+90,1
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1-90,1
ASKBOX CC3
Erase the reference entity?
IFERR MacroDone
LAYER ToErase
HIDEA
SELBYA
ERASE
SHOWA
REDRAW
:MacroDone
selby1
keep 10001,10001
selbyl
changel MacroConstruct
like
10001,10001
selbyp
group
selby1
erase 10001,10001
SELREST
ECON
RDON
ENDM
I change the layer to MacroConstruct after moving the entity to ToErase. The offset copy command seems to not only create an offset line, but it also copies all the parameters of the reference entity, including the layer value.
Pete
Just wonder, which version of CC are you using because ERASE has been replaced by ERA...
ECOFF
RDOFF
SELSAVE
POINT 10001,10001;
GE RefPoint 10001,10001
LWIDTH 0;LSTYLE solid;FSTYLE solid
GV varStepWidth 10
GV varStepWidth ^DEnter the stairway width [10]:
GV varStepDepth 1
GV varStepDepth ^DEnter the step spacing [1]:
GE varEntity ^DSelect the reference entity to draw the staircase along:
IFERR MacroDone
SELBY1
GOLAYER ToErase
CHANGEL varEntity ToErase
SELBY1
GOLAYER MacroConstruct
GLEN varEntityLen varEntity
GN varStepNum varEntityLen/varStepDepth
GV varUnit 100/varStepNum
GV varCurStep 0
GP varP1 % 0 varEntity
GBRNG varB1 varP1 % .01 varEntity
LINE ref varP1 <varB1+90,(varStepWidth/2) ref varP1 <varB1-90,(varStepWidth/2);
:Loop
GV varCurStep varCurStep+1
GP varP1 % (varCurStep*varUnit) varEntity
GBRNG varB1 varP1 % (varCurStep*varUnit)-.01 varEntity
LINE ref varP1 <varB1-90,(varStepWidth/2) ref varP1 <varB1+90,(varStepWidth/2);
IFP varStepNum-varCurStep Loop
SELBYP
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1+90,1
CHANGEL MacroConstruct
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1-90,1
CHANGEL MacroConstruct
ASKBOX CC3
Erase the reference entity?
IFERR MacroDone
LAYER ToErase
HIDEA
SELBYA
ERA
SHOWA
REDRAW
:MacroNoErase
LAYER MacroConstruct
:MacroDone
SELBY1
ERA RefPoint
SELREST
ECON
RDON
ENDM
I didn't found the way to change the layer to the one stored in the RefPoint, though...
But in your version, the point at 10001,10001 was included in the group.
Looks like it works, except on the changing layer feature...
And thank you for the help. I should have thought of the change layer command...
Thank you very much.
Pete
Added later:
Now I have a problem that the second staircase drawn will not only erase the reference line in the second staircase, but the first staircase in toto as well. I've tried using different layers for the staircases, saving and exiting CC3, nothing seems to prevent this from happening. It should be noted that it's just the staircase(s) that are deleted...anything else in the sheet/layer is not touched.
When I use the Info->List command on the grouped entity, all the lines in the group are on the starting layer. Running the macro a second time and NOT erasing the reference seems to have no effect on the layers of either grouped entity. Running the macro a third time and selecting TO erase the reference line, erases not only the reference line, but the previous two grouped entities. I am thoroughly confused...but then I'm new to this.
ASKBOX CC3
Erase the reference entity?
IFERR MacroDone
LAYER ToErase
HIDEA
SELBYA
ERASE
SHOWA
REDRAW
:MacroDone
selby1
layer MacroConstruct
selby1
keep 10001,10001
selbyl
changel MacroConstruct
like
10001,10001
selbyp
group
selby1
erase 10001,10001
Admittedly, Joachim's version does what I started out to do...but...I like the fact that the staircase is grouped into one entity and said entity's layer is changed to the starting value found in the point. So, why does this behavior happen? I'm sure it's something obvious.
I fully understand the wish to keep the entities grouped but I don't see any solution for the moment.
I'd recommend adding SAVESETTINGS after SELSAVE and GETSETTINGS before ENDM. This saves things like current layer, color, fill style etc. and restores them to the initial state.
ASKBOX CC3
Erase the reference entity?
IFERR MacroDone
LAYER ToErase
SELBYL
ERASE
ToErase
REDRAW
:MacroDone
SELBYL
CHANGEL MacroConstruct
LIKE
10001,10001
SELBYP
GROUP
SELBY1
ERASE 10001,10001
GETSETTINGS
SELREST
Like I said, this is thanks to Simon for pointing me in the right direction.
FatPete
MACRO STAIRCASE
ECOFF
RDOFF
SELSAVE
SAVESETTINGS
POINT 10001,10001;
LWIDTH 0;LSTYLE solid;FSTYLE solid
GV varStepWidth 10
GV varStepWidth ^DEnter the stairway width [10]:
GV varStepDepth 1
GV varStepDepth ^DEnter the step spacing [1]:
GE varEntity ^DSelect the reference entity to draw the staircase along:
IFERR MacroDone
SELBY1
GOLAYER ToErase
CHANGEL varEntity ToErase
SELBY1
GOLAYER MacroConstruct
GLEN varEntityLen varEntity
GN varStepNum varEntityLen/varStepDepth
GV varUnit 100/varStepNum
GV varCurStep 0
GP varP1 % 0 varEntity
GBRNG varB1 varP1 % .01 varEntity
LINE ref varP1 <varB1+90,(varStepWidth/2) ref varP1 <varB1-90,(varStepWidth/2);
:Loop
GV varCurStep varCurStep+1
GP varP1 % (varCurStep*varUnit) varEntity
GBRNG varB1 varP1 % (varCurStep*varUnit)-.01 varEntity
LINE ref varP1 <varB1-90,(varStepWidth/2) ref varP1 <varB1+90,(varStepWidth/2);
IFP varStepNum-varCurStep Loop
SELBYP
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1+90,1
CHANGEL MacroConstruct
OFFSETCPY (varStepWidth/2) varEntity ref varP1 <varB1-90,1
CHANGEL MacroConstruct
ASKBOX CC3
Erase the reference entity?
IFERR MacroDone
LAYER ToErase
SELBYL
ERA
ToErase
REDRAW
:MacroDone
SELBYL
CHANGEL MacroConstruct
LIKE
10001,10001
SELBYP
GROUP
SELBY1
ERA 10001,10001
GETSETTINGS
SELREST
RDON
ECON
ENDM