myf Posted June 28, 2011 Share Posted June 28, 2011 Hi, I want to select object with specific hatch fill and change the fill of the selected objects then. If possible with all objects in drawing (including groups and symbols) How can I reach this via vectorscript? thanks Quote Link to comment
myf Posted June 28, 2011 Author Share Posted June 28, 2011 Here is a peace of code, I can select the objects with the specified hatch, but i don't now how to set the hatch then (see Set????) and if it works, how to select the hatch in an interactive way... PROCEDURE CHHatch; PROCEDURE EditHatch( ObjHand : HANDLE ); BEGIN Set?????(ObjHand, ??? 'Hatchname'); ResetObject( ObjHand ); END; BEGIN ForEachObject( EditHatch, HFI='Hatchname' ); ReDrawAll; END; RUN(CHHatch); thanks for help Quote Link to comment
maarten. Posted June 28, 2011 Share Posted June 28, 2011 have a look at SetVectorFill in the Function Reference. Quote Link to comment
myf Posted June 29, 2011 Author Share Posted June 29, 2011 (edited) Thank You! I have to try out. How do you come from Foreachobj to SetVectorfill, it doesn't work like my first example. Just works with SetLW... I always get a "Function"-ERROR, how to use this Functions instead of Procedures Edited June 29, 2011 by myf Quote Link to comment
maarten. Posted June 29, 2011 Share Posted June 29, 2011 A wild guess, but maybe you forgot to assign the boolean to the function? This example will replace the hatch "Old Hatch" (on every object that has that hatch) with "New Hatch". PROCEDURE CHHatch; PROCEDURE EditHatch( ObjHand : HANDLE ); VAR bool : BOOLEAN; BEGIN bool:=SetVectorFill (ObjHand, 'New Hatch'); ResetObject( ObjHand ); END; BEGIN ForEachObject( EditHatch, HFI='Old Hatch' ); END; RUN(CHHatch); Quote Link to comment
myf Posted June 29, 2011 Author Share Posted June 29, 2011 Wow, I don't know why it works, but it works fine Dank je wel! Quote Link to comment
myf Posted June 30, 2011 Author Share Posted June 30, 2011 I found this example-code at http://www.nemetschek.net/support/custom/vscript/example.php to choose an Hatch, but I have no idea to get it combined the my ChHatch-Script above and get two times this window to choose the old Hatch and then the new one. Can someone explain me how to combine (these) scripts and get the VARs from one to another? PROCEDURE ImagePopTest; VAR gHatchList:dynarray[] of STRING; gHatchCount,gDlogID,gDlogResult : INTEGER; gHatchChoice : STRING; gOKdlog : BOOLEAN; FUNCTION BuildHatchList:INTEGER; VAR temp_i,temp_cnt:INTEGER; BEGIN temp_cnt := 0; FOR temp_i := 1 TO NameNum DO IF (getobject(namelist(temp_i)) <> NIL) & (gettype(getobject(namelist(temp_i))) = 66) THEN BEGIN temp_cnt := temp_cnt +1; allocate gHatchList[1..temp_cnt]; gHatchList[temp_cnt] := namelist(temp_i); END; BuildHatchList := temp_cnt; END; FUNCTION Define_Dialog: INTEGER; VAR dialogID,i : INTEGER; BEGIN dialogID := CreateLayout('Hatch Picker Dialog',True,'OK','Cancel'); CreateStaticText(dialogID,4,'Select the Hatch:',-1); CreateControl(dialogID,5,10,'',0); SetFirstLayoutItem(dialogID,4); SetBelowItem(dialogID,4,5,0,0); Define_Dialog := dialogID; END; PROCEDURE Drive_Dialog(VAR item:LONGINT; data:LONGINT); VAR temp_i,i:INTEGER; temp_s:STRING; result:BOOLEAN; BEGIN CASE item OF SetupDialogC: FOR i := 1 TO gHatchCount DO temp_i := InsertImagePopupObjectItem(gDlogID,5,gHatchList[i]); 1:gHatchChoice := GetImagePopupObject(gDlogID,5,getImagePopupSelectedItem(gDlogID,5)); END; {of CASE} END; BEGIN {MAIN} gHatchCount := BuildHatchList; gDlogID := Define_Dialog; gOKdlog := VerifyLayout(gDlogID); IF gOKdlog THEN gDlogResult := RunLayoutDialog(gDlogID,Drive_Dialog); IF (gDlogResult = 2) THEN alrtdialog('You canceled') ELSE alrtdialog(concat('You chose ',gHatchChoice)); END;Run(ImagePopTest); Thank You! Quote Link to comment
maarten. Posted June 30, 2011 Share Posted June 30, 2011 This one would work. I don't have the time now to explain the variable part though, sorry ... But ask along and i'm sure somebody would explain it how it works. PROCEDURE ImagePopTest; VAR gHatchList:dynarray[] of STRING; gHatchCount,gDlogID,gDlogResult : INTEGER; gHatchChoiceOld,gHatchChoiceNew,gCrit : STRING; gOKdlog : BOOLEAN; {Subfunction BuildHatchList} FUNCTION BuildHatchList:INTEGER; VAR temp_i,temp_cnt:INTEGER; BEGIN temp_cnt := 0; FOR temp_i := 1 TO NameNum DO IF (getobject(namelist(temp_i)) <> NIL) & (gettype(getobject(namelist(temp_i))) = 66) THEN BEGIN temp_cnt := temp_cnt +1; allocate gHatchList[1..temp_cnt]; gHatchList[temp_cnt] := namelist(temp_i); END; BuildHatchList := temp_cnt; END; {End Sub} {Subfunction Define_Dialog} FUNCTION Define_Dialog: INTEGER; VAR dialogID,i : INTEGER; BEGIN dialogID := CreateLayout('Hatch Picker Dialog',True,'OK','Cancel'); CreateStaticText(dialogID,4,'Select the old Hatch:',-1); CreateControl(dialogID,5,10,'',0); CreateStaticText(dialogID,6,'Select the new Hatch:',-1); CreateControl(dialogID,7,10,'',0); SetFirstLayoutItem(dialogID,4); SetBelowItem(dialogID,4,5,0,0); SetBelowItem(dialogID,5,6,0,0); SetBelowItem(dialogID,6,7,0,0); Define_Dialog := dialogID; END; {End Sub} {Subprocedure Drive_Dialog} PROCEDURE Drive_Dialog(VAR item:LONGINT; data:LONGINT); VAR temp_i,i:INTEGER; temp_s:STRING; result:BOOLEAN; BEGIN CASE item OF SetupDialogC: BEGIN FOR i := 1 TO gHatchCount DO temp_i := InsertImagePopupObjectItem(gDlogID,5,gHatchList[i]); FOR i := 1 TO gHatchCount DO temp_i := InsertImagePopupObjectItem(gDlogID,7,gHatchList[i]); END; 1: BEGIN gHatchChoiceOld := GetImagePopupObject(gDlogID,5,getImagePopupSelectedItem(gDlogID,5)); gHatchChoiceNew := GetImagePopupObject(gDlogID,7,getImagePopupSelectedItem(gDlogID,7)); END; END; END; {End Sub} {Subprocedure Drive_Dialog} PROCEDURE EditHatch( ObjHand : HANDLE ); VAR bool : BOOLEAN; BEGIN bool:=SetVectorFill (ObjHand,gHatchChoiceNew); ResetObject( ObjHand ); END; {End Sub} {MAIN} BEGIN gHatchCount := BuildHatchList; gDlogID := Define_Dialog; gOKdlog := VerifyLayout(gDlogID); IF gOKdlog THEN gDlogResult := RunLayoutDialog(gDlogID,Drive_Dialog); IF (gDlogResult = 2) THEN alrtdialog('You canceled') ELSE BEGIN gCrit:=ConCat('HFI=',Chr(39),gHatchChoiceOld,Chr(39)); ForEachObject(EditHatch,gCrit); END; END; Run(ImagePopTest); Quote Link to comment
myf Posted June 30, 2011 Author Share Posted June 30, 2011 Another time "WOW" you are great, i think i will need monthss to understand that, but i will try. Thanks to your nice written code, i can understand at least a little bit... Dank je well mika 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.