Jump to content
Developer Wiki and Function Reference Links ×

Help changing elevation script


Recommended Posts

Hello everyone

i have this script that worked till 2009.

Now i have 2011 and it gives me error. can you understand why?

 PROCEDURE FindYcoord;

VAR
x1, y1 : REAL;
x2, y2 : REAL;
x3, y3 : REAL;
y4, h1: REAL;
textArray : DYNARRAY[] OF CHAR;
h,hg:handle;
CurrentCl:string;

BEGIN

DSelectAll;

CurrentCl:=ActiveClass;
NameClass('cota altimetrica');
SetClUseGraphic(' cota altimetrica',true);
SetClPenFore(' cota altimetrica',0,0,0);
SetClPenBack(' cota altimetrica',0,0,0);
SetClLW(' cota altimetrica',1);
SetClLS(' cota altimetrica',5);
SetClFPat(' cota altimetrica',0);
ShowClass(' cota altimetrica');


LSByClass;
LWByClass;
PenColorByClass;
FillColorByClass;
FPatByClass;
NameClass(CurrentCl);

GetPt(x3,y3);

WHILE (h1 := 0) DO BEGIN

GetPt(x1,y1);
MoveTo(x1,y1);
x2 := x1 - 0.10;
Y2 := y1 + 0.17;
LineTo(x2,y2);

MoveTo(x1,y1);
x2 := x1 + 0.14;
Y2 := y1 + 0.25;
LineTo(x2,y2);

x2 := x2 + 0.6;
LineTo(x2,y2);


TextSize(6);
TextJust(2);
TextVerticalAlign(4);
x2 := x2 - 0.3;
y2 := y2 + 0.02;
TextOrigin (x2,y2);
FillPat(0);

y4 := y1 - y3;

BeginText;
Concat('',Num2StrF (y4) ,'' )
EndText;


Group;


DSelectAll
END;
END;
Run(FindYcoord);

My gold is to draw an personalized elevation symbol, find the y coordinate and put a text with elevation on it. The drawback is that i have to first set the origin by using vectorworks origin changer

Can you help me?

Thx in advanced

Edited by orlando Teixeira
Link to comment

Hello Orlando,

There appear to be two problems in the script that I can see. First,

???WHILE (h1 := 0) DO BEGIN?????{ THIS IS AN ERROR }

should read:

???WHILE (h1 = 0) DO BEGIN

or better:

???WHILE TRUE DO BEGIN

which is the same thing, as h1 is always 0, so it always evaluates to TRUE.

Second, these lines have a BLANK at the front of the Class Name:

???SetClUseGraphic(' cota altimetrica',true);

???SetClPenFore(' cota altimetrica',0,0,0);

???SetClPenBack(' cota altimetrica',0,0,0);

???SetClLW(' cota altimetrica',1);

???SetClLS(' cota altimetrica',5);

???SetClFPat(' cota altimetrica',0);

???ShowClass(' cota altimetrica');

but your NAMECLASS statement does not.

???NameClass('cota altimetrica');

They should be the same. Either add a blank to the former or remove the blanks from the latter.

I noticed your script does not put your elevation markers into the class "cota altimetrica". If you change your program to replace this line:

???GetPt(x1, y1);

with:

???NameClass(CurrentCl);

???GetPt(x1, y1);

???NameClass('cota altimetrica');

you should get the effect I think you are after. When the program exits, your class will be returned to the current class.

HTH,

Raymond

Link to comment
My gold is to draw an personalized elevation symbol, find the y coordinate and put a text with elevation on it. The drawback is that i have to first set the origin by using vectorworks origin changer

Orlando, you shouldn't have to change the User Origin. When this script is running the first click should be at the 0 elevation point to set your reference. No marker is placed on the first click. Markers get placed on all subsequent clicks until the script terminates.

Raymond

Link to comment

hello MullinRJ

it worked perfectly. Thx very very much

now just an ajust. How can i save the location of the first x1,y1 somewhere so

1)that when i re execute the script i can use that point ?

2) or perhaps do i have to loop it until i have enouth elevations so that the y ccordinate maintains ?

thx :)

p.s. sure you are correct i have no need to change origin because i allready have an control point :)

Edited by orlando Teixeira
Link to comment
how can i nake an symbol insted of group; ?

So, now you want to get fancy?

Well you picked a good example to show a neat feature of VW ? linking text to a symbol. If you create one symbol for every elevation marker you place, you'll end up with a lot of symbols that are all the same except for the value inside.

VW has a way of creating a symbol with dummy text inside that gets overwritten when the symbol gets placed in the drawing. The magic is in a record that also gets attached to the symbol that has the value you want displayed.

I modified your script to do just that. I commented the code to show how it works, but if you'd like further explanation, please write back.

Raymond

PROCEDURE FindYcoord;
{ Place a custom Elevation Marker symbol on the drawing that shows the elevation of where it was placed. }
{ The symbol does not update if moved. The symbol uses Linked Text to show the Elevation. }
{ If the symbol or record format do not exist when the script is run, they are created. }
{ To use, click once at the 0 Ref Elev. No marker is displayed, but the reference is stored. }
{ Subsequent clicks place Elevation Markers relative to the first click. } 
CONST
ElevClass = 'cota altimetrica';
ElevRec = 'ElevRec';	{ change this name to suit you }
ElevFld = 'ElevField';	{ change this name to suit you }
ElevSym = 'ElevSym';	{ change this name to suit you }
VAR
x1, y1 : REAL;
x3, y3 : REAL;
CurrentCl : STRING;

BEGIN
DSelectAll;

PushAttrs;	{ save graphic state }

CurrentCl := ActiveClass;
NameClass(ElevClass);
SetClUseGraphic(ElevClass, true);
SetClPenFore(ElevClass, 0, 0, 0);
SetClPenBack(ElevClass, 0, 0, 0);
SetClLW(ElevClass, 1);
SetClLS(ElevClass, 5);
SetClFPat(ElevClass, 0);
ShowClass(ElevClass);

LSByClass;
LWByClass;
PenColorByClass;
FillColorByClass;
FPatByClass;
NameClass(CurrentCl);	{ remove this line if you want the symbol parts in the Elev Class. }

{ Create the Record Format if it doesn't exist. }
IF (GetObject(ElevRec)=nil) then
	NewField(ElevRec, ElevFld, '0', 3, 0);

{ Create the Symbol if it doesn't exist. }
IF (GetObject(ElevSym)=nil) then begin
	BeginSym(ElevSym);
		MoveTo(-0.10, 0.17);
		LineTo(0, 0);
		LineTo(0.14, 0.25);
		LineTo(0.74, 0.25);

		TextSize(12);
		TextJust(2);
		TextVerticalAlign(4);
		TextOrigin (0.44, 0.27);
		FillPat(0);

		BeginText;
			Num2StrF(0.000)
		EndText;
		LinkText(LNewObj, ElevRec, ElevFld);
	EndSym;
end;	{ IF }

PopAttrs;	{ restore graphic state }

GetPt(x3, y3);	{ This is where the reference elevation is stored }

WHILE TRUE DO BEGIN
	NameClass(CurrentCl);	{ return to current class }
	GetPt(x1, y1);		{ Elevation marker will be placed at this point }
	NameClass(ElevClass);	{ Elev symbol instance goes in this class }

	SYMBOL(ElevSym, x1, y1, #0);
	SetRecord(LNewObj, ElevRec);
	SetRField(LNewObj, ElevRec, ElevFld, Num2StrF(y1 - y3));

	RedrawAll;
	DSelectAll
END;	{ WHILE }
END;
Run(FindYcoord);

Link to comment

Back once again

i am not finding the thing i wanna.

Can this be done:

1) somehow change data globaly, lets say if i had to increase or decrease my terrain 0,5m , now i have to edit individually each symbol. Can this be done selecting all the elevation markers, or by an worksheet, or something else ?

2) Add a menu so i can change class name?

3) Can we create an 2d locus (with a name if possible) so that the next time i do not have to make the origin point?

4) or even if possible use that 2d locus for changing global data as refered in point 1) ?

can any of this be possible ?

thx

Edited by orlando Teixeira
Link to comment

Orlando,

???You are very welcome. You are trying to move very fast from fancy to luxury. Most of what you are describing would require your static markers to be dynamic. To do that you would need to develop a Plug-In-Object. Definitely not as easy, but very much doable.

???If all you want to do is move everything up or down globally, with what you already have it would be much easier to write another script to adjust your markers. You can change the value stored in each record by a fixed amount and the symbols will then display the new value.

???Have a look at ForEachObject() or ForEachObjectInLayer() and have it modify the records of your symbol instances using SetRField(). You can search the TechBoard for examples of using these calls, several have been posted.

Raymond

Link to comment

hello MullinRJ

you got me, i am allways trying to take a longer step then my leg . . . but i get entusiastic and try to do stuff that i find possible.

I will have to start and learn basics first.

I think that this problem is because when i was in school it was easy for me to learn how to program in C for example but i had teachers . . now it has passed 10 years since i still guessing that it is easier than those days lol (by the way i dont remember how to programin c anymore lol)

Ok i will have a look at that more calmly..

Thx for your patience, and Pat's too :)

regards

Link to comment

by the way,

why do this script works fine but if i change it to:

AlrtDialog('Select Origin Point.');
GetPt(x3, y3);	{ This is where the reference elevation is stored }
b := RealDialog('Elevation Reference Height?', Concat(b));	{ ask for an elevation reference }
AlrtDialog('Select Elevation Markers Point of Elevation');
y3:= b;

the elevation goes in the wrong way?

example:

b:=0 final = 4,5

b:=1 final = 3,5 . . .

why is that ?

thx

p.s. but if i do the oposite way it works

example:

b:=0 final = 4,5

b:=-1 final = 5,5 . . .

p.s.II

of course if i change

SetRField(LNewObj, ElevRec, ElevFld, Num2StrF(y1 - y3));

to

SetRField(LNewObj, ElevRec, ElevFld, Num2StrF(y1 - (-y3)));

it also works, but why do i have this ???

thx :)

Edited by orlando Teixeira
Link to comment

hello, ppl

i got it figured it out . . MullinRJ

i was doing

..
..
SetRField(LNewObj, ElevRec, ElevFld, Num2StrF(y1 - (-y3)-0.07));
..
..

but in fact i should be doing ( i had relative height to simplify origin points)

..
..
b := RealDialog('2? - Relative Height?', Concat(b)); { ask for an elevation reference }
..
SetRField(LNewObj, ElevRec, ElevFld, Num2StrF((y1 - y3)+b));
..
..

so, now i have some questions:

1) how can i "save" origin point ? (save in a record the coordinates?)

2) how can i restrain the decimal places to 2 in records and in text(here suposly??.

for example the heigth is 5 it writes 5,00 (now it only shows the 5 number...)

3) i have a parameter to assign a class. this works fine the first time we make the symbol but not the next times of course. How can i change inside a symbol the class of the objets?

4) by the way you sayd it was doable to "move" this symbols is i change the height ? how ?

thx and regards

Link to comment

Hi Orlando,

???Good job.

1) Use GetOrigin, then save the values in a record format with NewField; or write them to a worksheet cell; or save them in a text block in a SymDef. Your choice.

2) Use Num2Str(Decimals, Number);

3) You can get the handle to the first object inside a symbol definition with:

???FInSymDef(GetObject('SymbolName'));

then get the rest with a WHILE or REPEAT loop and NextObj().

If you change the class of the symbol contents then it will be the same for all symbol instances of that symbol name in your file. Only the placed symbol instances can have different class names from each other. This may be what you want, but I'm not sure what you are trying to do.

4) Change the value in the attached record of your markers by the delta of your elevation move. Whatever value is in the attached record will display in the symbol. Use SetRField() once you get a handle to a symbol's attached record.

HTH,

Raymond

Link to comment

hello mullinRj

thx :)

1) i was asking for origin point of the tool script, therefore i have to do it with x3,y3 . . . i am such an..

2) hmm ok i have Num2StrF(0, 00); so i must have Num2Str(2,2) ??? . . .

3) you are allmost correct i wanna change inside the symbol and outside all the instances so i have to loop and FlnSym (...got to search this tonight)

4)yes i wanna do that but i wanna achieve to also move all the symbols that contain a certain value or all the symbols. (i think i will leave the final one to last because it will perhaps be an independent script because of the complexity??)

thx

regards

edit: point 2) my mistake i have to leave Num2StrF alone and :

First

..
..
{ Create the Record Format if it doesn't exist. }
IF (GetObject(ElevRec)=nil) then
	NewField(ElevRec, ElevFld, '0,00', 6, 2);
..
..

l8ter

..
..
SetRField(LNewObj, ElevRec, ElevFld, Num2Str(2,(y1 - y3)+b));
..
..

Edited by orlando Teixeira
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...