Exemple de funcții utile

<< Click to Display Table of Contents >>

Navigation:  WinArhi > Fereastra principala > Oferte si Comenzi deschise > Meniu > Optiuni > Editare Script funcții >

Exemple de funcții utile

OtelDacaCcvPeToc(CodOtel) - Trebuie marcată ca funcție pentru oțel. Adaugă oțelul daca este apelată de o cercevea care stă pe toc.

OtelDacaCcvNuPeToc(CodOtel)

 

 

//functia trebuie marcata ca si functie de Otel                                                                                                      

function OtelDacaCcvPeToc(ACodOtel: String): Boolean;

begin

 Result := True;

 //ccv = 3, toc = 1

 if (Val.PrType = 3) and (Val.FrameType = 1) then

   WA_AddCutItem(ACodOtel, 0);                                                                    

end;

 

//functia trebuie marcata ca si functie de Otel                                                                                                      

function OtelDacaCcvNuPeToc(ACodOtel: String): Boolean;

begin

 Result := True;

 //ccv = 3, toc = 1

 if (Val.PrType = 3) and (Val.FrameType <> 1) then

   WA_AddCutItem(ACodOtel, 0);                                                                    

end;

 

Exemplu pentru lista de tipuri de fereastra (în meniu Opțiuni->Setări->Liste):

function StabilesteTipFereastra: String;

const

 CoduriPrUsa = ['123456','112233'];            

var                  

 i: Integer;

 f: TWAFrame;

 s: TWASquare;                              

begin

 //Arcada                

 for i := 0 to Val.WindowDoor.FramesCount - 1 do begin

   f := Val.WindowDoor.Frames(i);

   if f.HasArch then begin            

     Result := 'Ar';

     Exit;                    

   end;                      

 end;

 //Forma

 for i := 0 to Val.WindowDoor.FramesCount - 1 do begin

   f := Val.WindowDoor.Frames(i);

   if not f.IsRectangle then begin            

     Result := 'Fr';

     Exit;                    

   end;                      

 end;

 //Culisanta dupa tip deschidere                                    

 for i := 0 to Val.WindowDoor.SquaresCount - 1 do begin

   s := Val.WindowDoor.Squares(i);

   if (s.OpeningType in ['CBD', 'CBS', 'CRD', 'CRS', 'CD', 'CS']) then begin            

     Result := 'C';                                            

     Exit;                    

   end;                      

 end;

 //Usa (0 este tocul, asa ca incepem de la 1)    

 for i := 1 to Val.WindowDoor.FramesCount - 1 do begin

   f := Val.WindowDoor.Frames(i);

   if (f.LeftPrCode in CoduriPrUsa)

   or (f.RightPrCode in CoduriPrUsa)                  

   or (f.TopPrCode in CoduriPrUsa)

   or (f.BottomPrCode in CoduriPrUsa) then begin            

     Result := 'U';

     Exit;                                

   end;                      

 end;

 //Fereastra, daca nu a stabilit altceva pana aici

 Result := 'F';

end;

 

Funcție de parcurgere a unei liste text cu cote separate de linie nouă și ajustarea fiecarei poziții. Funcția transformă milimetrii în inch într-o listă separată de linie nouă.

function TransformaMilimetriInInch(ALista: String): String;

var                  

 i: Integer;

 SList: TStringList;

begin

 SList := TStringList.Create;

 try  

   SList.Text := ALista;

   for i := 0 to SList.Count - 1 do

     SList[i] := WA_MilimeterToInch16(WA_StrToFloat(SList[i]));

   Result := SList.Text;

 finally

   SList.Free;

 end;

end;

 

Funcția primește ca parametru un text cu cote separate cu virgula si intoarce cotele in inch.

function TransformaMilimetriInInch(ALista: String): String;

var                  

 i: Integer;

 lst: array of String;

begin

 lst := WA_SplitString(ALista, ',');

 Result := '';

 for i := 0 to Length(lst) - 1 do

   Result := Result + WA_MilimeterToInch16(WA_StrToFloat(Trim(lst[i]))) + ', ';

 //stergem ultima virgula cu spatiu

 if Length(Result) >= 2 then

   SetLength(Result, Length(Result) - 2);

end;