Dieter @ DWorks Posted April 5, 2006 Share Posted April 5, 2006 how to I get the parameters of a plug-in object from a script that's not the object. I mean I have a script that looks for the objects and then it must count the parameters together. but how do I acces these parameters? Quote Link to comment
ccroft Posted April 6, 2006 Share Posted April 6, 2006 Get a handle to the object,get it's name and use GetRField. 'Record' is the name of the PIO and 'Field' is the name of the parameter field. Quote Link to comment
Dieter @ DWorks Posted April 6, 2006 Author Share Posted April 6, 2006 I tried that and it doesn't work? Quote Link to comment
Dieter @ DWorks Posted April 6, 2006 Author Share Posted April 6, 2006 GetRField returns nothing, GetObjectVariableReal gives also nothing Quote Link to comment
Rick Francken Posted April 6, 2006 Share Posted April 6, 2006 Hi, Can you show us the script you are using? We might be able to offer some hints on how to make it work. I use the GetRField extensively in scripts to query PIO parameters, and it works fine. But there are some things to watch out for. -Rick Francken www.franckensoft.com Quote Link to comment
Dieter @ DWorks Posted April 6, 2006 Author Share Posted April 6, 2006 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] Quote Link to comment
ccroft Posted April 8, 2006 Share Posted April 8, 2006 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 ] Quote Link to comment
Rick Francken Posted April 8, 2006 Share Posted April 8, 2006 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, Quote Link to comment
Dieter @ DWorks Posted April 10, 2006 Author Share Posted April 10, 2006 k, thx Str2Num gives no problem when I use ForEachObject. So there's no more problem, really thx Quote Link to comment
Recommended Posts
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.