Jump to content
Developer Wiki and Function Reference Links ×

Parameters of plug-in objects


Recommended Posts

I made an object myself for creating an opening:

code:

PROCEDURE Gevelopening;

VAR

breedte, hoogte :REAL;

rood, groen, blauw :LONGINT;

{$INCLUDE D - Klassen.vss}

BEGIN

Maak_Klassen;

breedte :=PBREEDTE;

hoogte :=PHOOGTE;

{-2D-}

NameClass('Loci - 2D');

Locus(-breedte/2,0);

Locus( breedte/2,0);

NameClass('Geen');

ColorIndexToRGB(0,rood,groen,blauw);

FillBack(rood,groen,blauw);

FillFore(rood,groen,blauw);

FillPat(1);

ColorIndexToRGB(0,rood,groen,blauw);

PenBack(rood,groen,blauw);

PenFore(rood,groen,blauw);

PenPat(0);

PenSize(0);

BeginPoly;

AddPoint((-breedte/2-5), 10);

AddPoint(( breedte/2+5), 10);

AddPoint(( breedte/2+5), 5);

AddPoint( breedte/2 , 5);

AddPoint( breedte/2 ,- 5);

AddPoint(( breedte/2+5),- 5);

AddPoint(( breedte/2+5),-10);

AddPoint((-breedte/2-5),-10);

AddPoint((-breedte/2-5),- 5);

AddPoint( -breedte/2 ,- 5);

AddPoint( -breedte/2 , 5);

AddPoint((-breedte/2-5), 5);

AddPoint((-breedte/2-5), 10);

EndPoly;

NameClass('Metselwerk - Gevel');

MoveTo((-breedte/2-5),5);

Line( 5, 0);

Line( 0,-10);

Line(-5, 0);

MoveTo((breedte/2+5),5);

Line(-5, 0);

Line( 0,-10);

Line( 5, 0);

NameClass('Metselwerk - Onzichtbaar');

MoveTo(-breedte/2,-5);

Line(breedte,0);

NameClass('Metselwerk - Zichtbaar');

MoveTo((-breedte/2-5),-5);

Line( 0,-5);

Line((breedte+10), 0);

Line( 0, 5);

{-3D-}

NameClass('Loci - 3D');

Locus3D(-breedte/2,0,230);

Locus3D( breedte/2,0,230);

Locus3D(-breedte/2,0,(205-hoogte));

Locus3D( breedte/2,0,(205-hoogte));

NameClass('Metselwerk - Gevel');

BeginXtrd(210,230);

Rect(-breedte/2,5,breedte/2,-5);

EndXtrd;

NameClass('Gesteenten - Arduin');

BeginXtrd((205-hoogte),(210-hoogte));

Rect((-breedte/2-5),10,(breedte/2+5),-10);

EndXtrd;

END;

run(Gevelopening);
[/code]

Now I want to use the parameters for the object to count how much meters there are, so I need the width

code:

PROCEDURE Bereken_Prijs;

VAR

h_rollaag :REAL;

laag_naam :STRING;

laag_handle :HANDLE;

object_handle :HANDLE;

{$INCLUDE D - Lagen.vss}

{$INCLUDE D - Klassen.vss}

FUNCTION Prijs_Ruwbouwwerken:REAL;

BEGIN

Prijs_Ruwbouwwerken:=

+ 9.92*1.27*h_rollaag {Rollagen boven gevelopeningen};

END;

BEGIN

Maak_Lagen;

Maak_Klassen;

h_rollaag :=0;

laag_handle:=FLayer;

WHILE laag_handle<>NIL DO BEGIN

laag_naam:=GetLName(laag_handle);

Layer(laag_naam);

DSelectAll;

SelectObj(C='Schrijnwerk - Opening');

object_handle:=FSObject(laag_handle);

WHILE object_handle<>NIL DO BEGIN

h_rollaag:=h_rollaag+Str2Num(GetRField(object_handle,'D - Gevelopening','Breedte'));

object_handle:=NextSObj(object_handle);

END;

laag_handle:=NextLayer(laag_handle);

END;

END;

run(Bereken_Prijs);
[/code]

Link to comment

What happens if you place one D - Gevelopening object in a blank drawing and run something lke this from a script palette:

Message(GetRField(FActLayer,'D - Gevelopening','Breedte'));

Does it still return nothing?

Assuming you get the correct result. If your second script is running inside a PIO and trying to use parameter values of other PIO's for it's own creation, you must find a way to loop thru the other PIO's that doesn't use selection. It's because of the way a PIO generates itself...the other PIO's aren't selected yet.

You are selecting your PIO's based on class criteria, and then using their selected status to get handles. You can use class criteria directly and eliminate selection. Have you investigated ForEachObject?

[ 04-07-2006, 11:40 PM: Message edited by: ccroft ]

Link to comment

Hi someonenamedlink,

One possible problem may be with the use of "Str2Num" function to convert the parameter value form string to floating point number. I had trouble with this one working on certain number formats, so I use "ValidNumStr" and "ValidAngStr" instead.

Try breaking your call down to several lines of code so that you can inspect the variable values more easily in the debugger. Maybe something like this:

procedure CalculateTotalMeters;

var

TotalLength: real;

BreedteStr: string;

BreedteVal: real;

{procedure used by "ForEachObject" call}

procedure AddLength(hGevel: handle);

begin

{get the Parameter's contents in string form}

BreedteStr:= GetRField(hGevel,'D - Gevelopening','Breedte');

{try to convert string contents to real, and provide a default value if "ValidNumStr"} fails}

{NOTE: be sure to inspect the values of BreedteStr and BreedteVal, and whether ValidNumStr is failing.}

if not ValidNumStr(BreedteStr, BreedteVal) then

BreedteVal:= 0;

{add the floating point value to the Total length}

TotalLength:= TotalLength + BreedteVal;

end;

{main code block}

begin

{StartWith a total length of 0.0}

TotalLength:= 0.0;

{iterate through all the PIOs with ForEachObject;}

ForEachObject(AddLength, (R IN ['D - Gevelopening']);

{Now do something with TotalLength}

Message(TotalLength);

end;

Good luck,

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