Jump to content
Developer Wiki and Function Reference Links ×

Creating double lines in a script / PIO


Pi_

Recommended Posts

Hi,

I'm working on a bunch of PIO to draw reinforcemnt bars in concrete colums, beams, ...

I need to create a double line that can be selfintersecting. So far I have the coordinates of the centerline and now I want to draw the outerline and the complete contour. I can not use the offset command because it give unpredictable results on selfintersecting lines. I've been trying with the calltool/settool(-218) command but I can't give input coordinates. Is het calltool only for creating objects outside of the PIO? or is there a command like "setpoint" that give an input to the calltool(-218) command.

Any help is welcome!

VW12.5 on windows XP

Link to comment

Thanks for the reply, seems we are working in the same city as I work at st pieters station!

Offcourse I ment polyline instead of line. I have made 2 dynarray of longint, one for the X-coordinates and one for the Y-coordinates. Drawing the centerline is not the problem, but now I want to draw the complete reinforcement bar (Innerline and outside line). If I could just draw a "double polygon" I can use the same coordinates...

Link to comment

this is the code so far...:

{///////////////////////////////////////////

Wapening_plooi

door Piet Lelieur voor studieburo Mouton okt 2009

creer een wapeningsplooi met bijbehorende tekst

//////////////////////////////////////////// }

PROCEDURE Wapening_plooi;

VAR

thoogte,i,j,k,l,vertexType,straal,plooidia,labelhoogte,positie : INTEGER;

breedte,hoogte,x,y, vertexRadius,rotatie,tekstX,tekstY : REAL;

labelx1,labelx2,labely1,labely2 : REAL;

result,tekst,afronden,labelaan : BOOLEAN;

objname,labelplooi,tekstplooi,zicht,tekenstijl,prefix,suffix,plooidata,plooidata2 : STRING;

coordinaat1,coordinaat2,teststring : STRING;{lengtes in tekst vorm}

oh,rh,wh,th,th2,polyh1,polyh2,polyh3,layerh ,parenth,grouph : HANDLE;

objevent,eventdata,X1,Y1,X2,Y2,test : LONGINT;

LAYOUTplooi,LAYOUTLAYOUT : BOOLEAN;

data,datateken,asx,asy : DYNARRAY of LONGINT;

BEGIN

{ retrieve custom object information }

result:= GetCustomObjectInfo(objname,oh,rh,wh);

{ if object information was successfully retrieved }

IF result THEN BEGIN

{ retrieve predefined parameter values }

tekstX :=PControlPoint01X;

tekstY :=PControlPoint01Y;

{ retrieve user-defined parameter values }

tekst :=Ptekst;

thoogte := Pteksthoogte;

plooidia := Pplooidia;

afronden:=Pafronden;

straal:=(Pstraal/2);{gebruiker geeft de buigdoorndiameter op}

labelplooi:=Plabelplooi;

tekenstijl:=Ptekenstijl;

labelaan:=Plabelaan;

labelhoogte:=Plabelhoogte;

LAYOUTPLOOI:=PLAYOUTPLOOI;

LAYOUTLAYOUT:=PLAYOUTLAYOUT;

prefix:=Pprefix;

suffix:=Psuffix;

plooidata:=Pplooidata;

{reken andere variabelen uit}

layerh:= getlayer(oh);

parenth:=GetParent(oh);

if parenth<>layerh then rotatie :=GetSymRot(parenth){als deze PIO gebruikt wordt binnen een andere PIO gebruik dan de parent hoek}

else rotatie:=GetSymRot(oh);

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{zet alles volgens klasse}

PushAttrs; {Stores current attribute, tool, text, and constraint settings for later retrieval}

FPatByClass;

FillcolorByClass;

LsByClass;

LwByClass;

PenColorByClass;

{tekst aan of uit}

if (NOT(tekst)) THEN SetParameterVisibility(oh,'teksthoogte',FALSE);

{label aan of uit}

if (NOT(labelaan)) THEN SetParameterVisibility(oh,'labelhoogte',FALSE);

{automatisch afronden}

if afronden THEN BEGIN

if (plooidia<20) Then straal:=(2*plooidia)

Else straal:=(3.5*plooidia);

SetParameterVisibility(oh,'straal',FALSE);

setRfield(oh,'Wapening_plooi','straal',CONCAT(2*straal));

END;

{LAyout}

if not LAYOUTPLOOI THEN BEGIN

SetParameterVisibility(oh,'plooidata',FALSE);

SetParameterVisibility(oh,'Labelplooi',FALSE);

SetParameterVisibility(oh,'plooidia',FALSE);

SetParameterVisibility(oh,'afronden',FALSE);

SetParameterVisibility(oh,'straal',FALSE);

END;

if not LAYOUTLAYOUT THEN BEGIN

SetParameterVisibility(oh,'tekenstijl',FALSE);

SetParameterVisibility(oh,'labelaan',FALSE);

SetParameterVisibility(oh,'tekst',FALSE);

SetParameterVisibility(oh,'labelhoogte',FALSE);

SetParameterVisibility(oh,'teksthoogte',FALSE);

SetParameterVisibility(oh,'tekstplooi',FALSE);

END;

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{berekenen van coordianten}

j:=1;

plooidata2:=plooidata;

While ((pos('+',plooidata2)<>0) or (pos('-',plooidata2)<>0)) Do Begin {tellen van het aantal coordinaten}

if min((pos('+',plooidata2)),(pos('-',plooidata2)))=0 then positie:= max((pos('+',plooidata2)),(pos('-',plooidata2))){er is geen min of plus teken meer maar wel een plus of min teken}

else positie:= min((pos('+',plooidata2)),(pos('-',plooidata2)));{vind het eerst volgende + of - teken}

delete(plooidata2,1,positie);

j:=j+1;

END;

ALLOCATE data[1..j+1];

ALLOCATE datateken[1..j+1];

plooidata2:=plooidata;

positie:=1;

i:=1;

k:=1;{geeft het teken aan de coordinaat , altijd beginnen met een positieve coordinaat}

{vul een array data met de waarden en een arrat datateken met het teken (+1 of -1)}

While i<= j Do Begin

if min((pos('+',plooidata2)),(pos('-',plooidata2)))=0 then

positie:= max((pos('+',plooidata2)),(pos('-',plooidata2))){er is geen min en plus teken meer maar wel ??n plus of min teken}

else positie:= min((pos('+',plooidata2)),(pos('-',plooidata2)));{vind het eerst volgende + of - teken}

if positie=0 then coordinaat1:=copy(plooidata2,1,len(plooidata2)){copier de laatste coordinaat}

else begin

coordinaat1:=copy(plooidata2,1,(positie-1));{copier de coordinaat}

coordinaat2:=copy(plooidata2,positie,1);{copier de + of -}

delete(plooidata2,1,positie);

END;

data:=str2num(coordinaat1);

datateken:=k;

if coordinaat2='+' then k:=1 else if coordinaat2='-' then k:=-1 ;{leg het teken vast voor de volgende coordinaat}

i:=i+1;

END;

i:=1;

teststring:='data: ';

While (i<=j) do begin

teststring:=CONCAT(teststring,CONCAT(data),',');

i:=i+1;

END;

message(teststring);

{EINDE berekenen van coordianten}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{TEXTSTRING plooi}

i:=1;

while i<=j DO BEGIN

tekstplooi:=CONCAT(tekstplooi,'+',CONCAT(data));

i:=i+1;

END;

tekstplooi:=CONCAT('(',labelplooi,') ',' ?',CONCAT(plooidia),prefix,'(',tekstplooi,')',suffix,chr(13));

setRfield(oh,'Wapening_plooi','tekstplooi',tekstplooi);

{EINDE TEXTSTRING plooi}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{BEGIN ZET TEKST}

IF tekst THEN BEGIN

{ zet de tekst samen rechts naast de balk }

IF tekst THEN BEGIN

CASE (ROUND(GetLScale(layerh))) OF {zet op de juiste layer}

0..5: nameclass('6.9 tekst en diverse');

6..10: nameclass('5.9 tekst en diverse');

11..10000: nameclass('4.9 tekst en diverse');

END;

Textsize(thoogte);

CreateText(tekstplooi);

th := LNEWOBJ;

SetTextJust(th,1);

SetTextVerticalAlign(th,1);

SetTextOrientation(th,tekstX,tekstY,-rotatie,FALSE);

END;

END;

{EINDE ZET TEKST}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{bepaal eerst de aslijn coordinaten}

allocate asx[0..j];

allocate asy[0..j];

asx[0]:=0;

asy[0]:=0;

asx[1]:=datateken[1]*(data[1]-plooidia/2);

asy[1]:=0;

i:=2;

While i<=j+1 Do BEGIN

if i>2 then begin

asy[i-1]:=asy[i-2];

asx[i-1]:=asx[i-2]+datateken[i-1]*(data[i-1]-plooidia);

END;

if i<=j then begin

asy:=asy[i-1]+datateken*(data-plooidia);

asx:=asx[i-1];

END;

i:=i+2;

END;

i:=1;

teststring:=CONCAT(teststring,' coordinaten aslijn: ');

While (i<=j) do begin

teststring:=CONCAT(teststring,CONCAT(asx),',',CONCAT(asy),'/');

i:=i+1;

END;

message(teststring);

{EINDE bepalen van de buitencontour, als basis voor de rest}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{LABEL plaatsen}

if labelaan then begin

CASE (ROUND(GetLScale(layerh))) OF {zet op de juiste layer}

0..5: nameclass('6.9 tekst en diverse');

6..10: nameclass('5.9 tekst en diverse');

11..10000: nameclass('4.9 tekst en diverse');

END;

Textsize(labelhoogte);

createtext(labelplooi);

th:=LNewOBJ;

SetTextJust(th,1);

SetTextVerticalAlign(th,5);

SetTextOrientation(th,0,0,-rotatie,FALSE);

th2:=HDuplicate(th,0,0);

SetTextJust(th2,1);

SetTextVerticalAlign(th2,1);

SetTextOrientation(th2,X1,Y1,-rotatie,FALSE);

END;

{EINDE LABEL plaatsen}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{ teken de plooi}

{aslijn}

If tekenstijl='Aslijn' then begin

i:=1;

OpenPoly;

Beginpoly;

Addpoint(0,0);

While (i<=j) Do Begin

Addpoint(asx,asy);

i:=i+1;

END;

Endpoly;

polyh1:=LNewObj;

END;

{aslijn}

If tekenstijl='Volledig' then begin

SetDLSeparation(plooidia);

SetDLOptions(1);

calltool(-218);

END;

{EINDE VAN ZIJAANZICHT}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

{________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________}

END;

PopAttrs; {Restores the attribute, tool, and constraint settings saved by an earlier call to PushAttrs}

END;

Run(Wapening_plooi);

Link to comment

Hey Piet,

I will see at the script next week, but there is a procedure for offsetting a shape. OffsetPoly should do what you want. I believe it's relyable in most cases, but if you want to make sure, You'll have to create a procedure yourself where you calculate all points. Its very doable. You can find OffsetPoly here: http://scs-inc.us/Other/VSFR/ with all other functions and procedures.

PS: Ik werk op een tekenbureau die normaal voor jullie ging werken, maar we hebben niets meer teruggehoord van jullie. ;)

Link to comment

I tried to look at the code, but it was very hard to read, thereby I refactored the code a bit and put the remarks to get better readable code. Most of them are general tips.

{*** WapeningPlooi ***}
{*** Door Piet Lelieur voor studieburo Mouton. ***}
{*** Edited by Dieter Geerts @ DWorks. ***}
{*** Octobre 2009 ***}

{*** Cre?er een wapeningsplooi met bijbehorende tekst. ***}

{** REMARKS by Dieter Geerts @ DWorks. **}

{* 00. I couldn't test this because I do not have the pio file, but normally it should work. If not, just let me know the trown bugs. *}
{* 01. Use tabs and other things to structure your code, this will make it easier to read.*}
{* 02. Use descriptive names, this will make your code easier to read and understand by others and yourself when you edit code that you have written a long time ago. *}
{* 03. Use subprocedures to split up your code, this makes it easier to work in and easier to read and understand. *}
{* 04. Split your vars into smaller groups and on more lines, again for readability. *}
{* 05. Type keywords in CAPS, again for readability because we don't have colors in the VS editor. *}
{* 06. You state that if the pio is in another pio, you need to get the parent angle, but realize that the parent can also be a group or a symbol, this can affect your code. *}
{* 07. Your PopAttrs was outside the Main IF statement while your PushAttrs was in it. This can give errors. Every PopAttrs must have a PushAttrs. This kind of faults can be avoided by structuring your code more so it's much more clear. *}
{* 08. You set the attributes by class in the script. This is ok, but not needed IF the classes have the option turned on for setting the attributes of new created object by class. This because everytime the script runs, all is redrawn, so if you put the option on later, it's ok too. But it's not a big deal if you do. *}
{* 09. You use ConCat to convert a number to a string. This can be done, but isn't recomended. It's far better to use Num2Str. With Num2Str you can control the conversion. You can choose the number of significant digits. If the digits doesn't matter, you can simply choose -1 to have the least rounding error. The thing here is that all fields of a pio, no matter if they are numbers, must be set by strings. But after they are set, VW convert them to the correct data type. So why shouldn't you use Num2Str with decimal place set to -1? No matter what number it is, VW will show it in the OIP with the document unit settings. *}
{* 10. Why allocating an array with the number of coordinates +1? That's one too much. *}
{* 11. You can do the whole coordinate calculation much faster and easier. See code below. *}
{* 12. You now store all coordinate data in one string field. If you are sure that you never exceed the maximum number of chars that's possible in such a string field, then it's fine, otherwise, this can go wrong, ending up with loss of coordinate data. So maybe you should consider another method of saving the coordinates? I don't know how you retrieve them or how the user puts them in, but you can do different things. You can add a field for each coordinate. You can always add fields to any pio by the way. Or you can use the path container of the pio to store a polygon where the x or y coordinates of each point are the ones you need to save? *}
{* 13. Some WHILE loops can be changed in FOR loops. There are easier to read. *}
{* 14. When using SetRField, the second parameter is the pio name, so use the name you retrieve with GetCustomObjectInfo instead of hard coding it. When the name changes, you then don't have to change it on all those places. *}
{* 15. In the piece for creating the text, you did control twice if the parameter text was checked. *}
{* 16. You use string literals for assigning classes. What if you want to change those? Then you have to change them on all places. Try thinking to use constants. These constants are on the top of the document and if they change, then you only have to change them once. *}
{* 17. The CallTool and SetTool commands are used for setting are calling the given tool so that you can get user input. *}
{* 18. Now that we have cut the code into pieces of procedures, we need to check if some variables are only used in one procedure and then move that var from the main var block to the var block of that procedure. *}
{* 19. There are many other things that can be done, but I think this code is just a piece of the pio, so it's hard to say what can be done exactly, but I hope you get the point. Just try to keep the main piece as short and clean as possible. *}


PROCEDURE WapeningPlooi;

VAR
result : BOOLEAN;

pioName : STRING;
pioHandle : HANDLE;
pioRecord : HANDLE;
pioWall : HANDLE;

tekst : BOOLEAN;
tekstX, tekstY : REAL;
tekstHoogte : INTEGER;

plooidata : STRiNG;
plooidia : INTEGER;
afronden : BOOLEAN;
straal : INTEGER;

labelPlooi : STRING;
labelAan : BOOLEAN;
labelHoogte : INTEGER;
prefix : STRING;
suffix : STRING;

tekenstijl : STRING;
LAYOUTPLOOI : BOOLEAN;
LAYOUTLAYOUT : BOOLEAN;

layerHandle : HANDLE;
parentHandle : HANDLE;

rotatie : REAL;

signPosition : INTEGER;
coordinateCount : INTEGER;
coordinateLength : INTEGER;
plooidataCopy : STRING;

data : DYNARRAY[] of LONGINT;
datateken : DYNARRAY[] of LONGINT;

counter01 : INTEGER;
testString : STRING;
tekstPlooi : STRING;
tekstHandle : HANDLE;
tekstHandle2 : HANDLE;

asX, asY : DYNARRAY[] of LONGINT;

k, l, vertexType : INTEGER;
breedte, hoogte, x, y, vertexRadius : REAL;
labelx1, labelx2, labely1, labely2 : REAL;
zicht : STRING;
coordinaat1, coordinaat2 : STRING; { Lengtes in tekst vorm }
polyh1, polyh2, polyh3, grouph : HANDLE;
objevent, eventdata, X1, Y1, X2, Y2, test : LONGINT;

PROCEDURE GetParameters();
BEGIN
	{* Retrieve predefined parameter values *}
	tekstX := PControlPoint01X;
	tekstY := PControlPoint01Y;

	{* Retrieve user-defined parameter values *}
	tekst := Ptekst;
	tekstHoogte := Pteksthoogte;

	plooidata := Pplooidata;
	plooidia := Pplooidia;
	afronden := Pafronden;
	straal:= (Pstraal/2); {Gebruiker geeft de buigdoorndiameter op.}

	labelPlooi := Plabelplooi;
	labelAan := Plabelaan;
	labelHoogte := Plabelhoogte;
	prefix := Pprefix;
	suffix := Psuffix;

	tekenstijl := Ptekenstijl;
	LAYOUTPLOOI := PLAYOUTPLOOI;
	LAYOUTLAYOUT := PLAYOUTLAYOUT;
END;

PROCEDURE AdjustParameters();
BEGIN
	{* Reken andere variabelen uit. *}
	layerHandle := GetLayer(pioHandle);
	parentHandle := GetParent(pioHandle);

	{* Als deze PIO gebruikt wordt binnen een andere PIO (of groep, of symbool), gebruik dan de parent hoek. *}
	IF parentHandle <> layerHandle THEN BEGIN
		rotatie := GetSymRot(parentHandle);
	END ELSE BEGIN
		rotatie := GetSymRot(pioHandle);
	END;

	{* Automatisch afronden. *}
	IF afronden THEN BEGIN
		IF (plooidia < 20) THEN BEGIN
			straal := 2*plooidia;
		END ELSE BEGIN
			straal := 3.5*plooidia;
		END,
		setRfield(pioHandle, pioName, 'straal', Num2Str(-1, 2*straal));
	END;
END;

PROCEDURE SetParameterVisibilities();
BEGIN
	{* Tekst aan of uit. *}
	IF NOT tekst THEN SetParameterVisibility(pioHandle, 'teksthoogte', False);
	{* Label aan of uit. *}
	IF NOT labelAan THEN SetParameterVisibility(pioHandle, 'labelhoogte', False);
	{* Automatisch afronden. *}
	IF afronden THEN SetParameterVisibility(pioHandle, 'straal', False);
	{* Layout. *}
	IF NOT LAYOUTPLOOI THEN BEGIN
		SetParameterVisibility(pioHandle, 'plooidata', False);
		SetParameterVisibility(pioHandle, 'Labelplooi', False);
		SetParameterVisibility(pioHandle, 'plooidia', False);
		SetParameterVisibility(pioHandle, 'afronden', False);
		SetParameterVisibility(pioHandle, 'straal', False);
	END;
	IF NOT LAYOUTLAYOUT THEN BEGIN
		SetParameterVisibility(pioHandle, 'tekenstijl', False);
		SetParameterVisibility(pioHandle, 'labelaan', False);
		SetParameterVisibility(pioHandle, 'tekst', False);
		SetParameterVisibility(pioHandle, 'labelhoogte', False);
		SetParameterVisibility(pioHandle, 'teksthoogte', False);
		SetParameterVisibility(pioHandle, 'tekstplooi', False);
	END;
END;

PROCEDURE CalculateCoordinates();
VAR
	foundChar : CHAR;

BEGIN
	{* Berekenen van coordinaten. *}
	{* I'm assuming that plooidata starts with a sign and that every sign has a number after it. *}

	coordinateCount := Len(plooidata); {There can't be more coordinates then the length of the string and if there is a number for each sign, you can half the count!}
	ALLOCATE data[1..coordinateCount];
	ALLOCATE datateken[1..coordinateCount];

	coordinateCount := 1;
	coordinateLength := 0;
	charIndex := 1;
	datateken[coordinateCount] := Copy(plooidata, charIndex, 1);
	charIndex := 2;
	WHILE NOT (charIndex > Len(plooidata)) DO BEGIN
		foundChar := Copy(plooidata, charIndex, 1);

		IF foundChar = "-" | foundChar = "+" THEN BEGIN
			data[coordinateCount] := Copy(plooidata, charIndex - coordinateLength, coordinateLength);
			coordinateCount := coordinateCount + 1;
			coordinateLength := 0;
			datateken[coordinateCount] := Copy(plooidata, charIndex, 1);
		END ELSE BEGIN
			coordinateLength := coordinateLength + 1;
		END;

		charIndex := charIndex + 1;
	END;
	data[coordinateCount] := Copy(plooidata, charIndex - coordinateLength, coordinateLength);

	{* Because we allocated the arrays too big, we must allocate them now with the real number of coordinates, thus deleting the empty spaces.}
	ALLOCATE data[1..coordinateCount];
	ALLOCATE datateken[1..coordinateCount];

	testString := 'Data: ';
	FOR counter01 := 1 TO coordinateCount DO BEGIN
		testString := ConCat(testString, CONCAT(data[counter01]), ',');
	END;
	message(testString);
END;

PROCEDURE CalculateAxisCoordinates();
BEGIN
	ALLOCATE asX[0..coordinateCount];
	ALLOCATE asY[0..coordinateCount];

	asX[0] := 0;
	asY[0] := 0;
	asX[1] := dataTeken[1] * (data[1] - plooidia/2);
	asY[1] := 0;

	counter01 := 2;
	WHILE i <= coordinateCount + 1 DO BEGIN
		IF counter01 > 2 THEN BEGIN
			asY[counter01-1] := asY[counter01-2];
			asX[counter01-1] := asX[counter01-2] + datateken[counter01-1] * (data[counter01-1] - plooidia);
		END;
		IF counter01 <= coordinateCount THEN BEGIN
			asY[counter01] := asY[counter01-1] + datateken[counter01] * (data[counter01] - plooidia);
			asX[counter01] := asX[counter01-1];
		END;
		counter01 := counter01 + 2;
	END;

	counter01 := 1;
	testString := CONCAT(testString, 'Coordinaten aslijn: ');
	WHILE (counter01 <= coordinateCount) DO BEGIN
		testString := CONCAT(testString, CONCAT(asX[counter01]), ',', CONCAT(asY[counter01]), '/');
		counter01 := counter01 + 1;
	END;
	Message(testString);
END;

PROCEDURE SetPlooiText();
BEGIN
	FOR counter01 := 1 TO coordinateCount DO BEGIN
		tekstPlooi:=CONCAT(tekstPlooi,'+',CONCAT(data[i]));
	END;

	tekstPlooi := CONCAT('(', labelPlooi, ') ', ' ?', CONCAT(plooidia), prefix, '(', tekstPlooi, ')', suffix, chr(13));
	setRfield(pioHandle, pioName, 'tekstplooi', tekstPlooi);
END;

PROCEDURE SetAttributesByClass();
BEGIN
	{* Zet alles volgens klasse. *}
	FPatByClass;
	FillColorByClass;
	LSByClass;
	LWByClass;
	PenColorByClass;
END;

PROCEDURE DrawText();
BEGIN
	{* Zet de tekst samen rechts naast de balk. *}
	IF tekst THEN BEGIN
		{* Set the correct class on active. *}
		CASE (ROUND(GetLScale(layerHandle))) OF
			0..5: NameClass('6.9 tekst en diverse');
			6..10: NameClass('5.9 tekst en diverse');
			11..10000: NameClass('4.9 tekst en diverse');
		END;
		Textsize(tekstHoogte);
		CreateText(tekstPlooi);
		tekstHandle := LNewObj;
		SetTextJust(tekstHandle, 1);
		SetTextVerticalAlign(tekstHandle, 1);
		SetTextOrientation(tekstHandle, tekstX, tekstY, -rotatie, False);
	END;
END;

PROCEDURE DrawLabel;
BEGIN
	IF labelAan then begin
		{* Set the correct class on active. *}
		CASE (ROUND(GetLScale(layerHandle))) OF
			0..5: NameClass('6.9 tekst en diverse');
			6..10: NameClass('5.9 tekst en diverse');
			11..10000: NameClass('4.9 tekst en diverse');
		END;
		Textsize(labelHoogte);
		createtext(labelPlooi);
		tekstHandle := LNewObj;
		SetTextJust(tekstHandle, 1);
		SetTextVerticalAlign(tekstHandle, 5);
		SetTextOrientation(tekstHandle, 0, 0, -rotatie, False);
		tekstHandle2:=HDuplicate(tekstHandle, 0, 0);
		SetTextJust(tekstHandle2, 1);
		SetTextVerticalAlign(tekstHandle2, 1);
		SetTextOrientation(tekstHandle2, X1, Y1, -rotatie, False);
	END;
END;

PROCEDURE DrawPlooi();
BEGIN
	{* Aslijn. *}
	IF tekenStijl = 'Aslijn' THEN BEGIN
		OpenPoly;
		Beginpoly;
			AddPoint(0, 0);
			FOR counter01 := 1 TO coordinateCount DO BEGIN
				AddPoint(asX[counter01], asY[counter01]);
			END;
		Endpoly;
		polyh1 := LNewObj;
	END;

	{* Aslijn. *}
	IF tekenStijl = 'Volledig' THEN BEGIN
		SetDLSeparation(plooidia);
		SetDLOptions(1);
		CallTool(-218);
	END;
END;

{** MAIN **}
BEGIN
{* Retrieve custom object information. *}
result := GetCustomObjectInfo(pioName, pioHandle, pioRecord, pioWall);


{* If object information was successfully retrieved. *}
IF result THEN BEGIN
	GetParameters;
	AdjustParameters;
	SetParameterVisibilities;

	CalculateCoordinates;
	CalculateAxisCoordinates;
	SetPlooiText;

	PushAttrs; {Stores current attribute, tool, text, and constraint settings for later retrieval.}
		SetAttributesByClass;
		DrawText;
		DrawLabel;
		DrawPlooi;
	PopAttrs; {Restores the attribute, tool, and constraint settings saved by an earlier call to PushAttrs.}
END;
END;

Run(WapeningPlooi);

Link to comment
  • 3 weeks later...

Hey Dieter,

thank you so much for all the good tips and tricks you gave me, I'll have to take my time to read and learn it all.

I think it is clear to you that I'm not a professional programmer. I just started with some small scripts here at my new job and after a month I was writing this more complex stuff...(my supervisor got enthousiastic about PIOs). You are absolutely wright about structuring the code!

After your first answer I took a whole new approach to the problem with a new input that made it easier to code. Now the input for bending a reinforcement bar is like this: 100+500+200-300-200...

positive values meaning turning 90? left and negative values meaning turning right. that made it much easier to calculate the inside and outside line of the reinforcement bar!

I'll try your code and let you know how it works but I have a working PIO allready so there is no hurry anymore. But like I said, your general tips and tricks are more important for me now! When we meet in Gent you've earned definitely a Westmalle triple or any other belgian beer!

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...