kiwi Posted December 3, 2003 Share Posted December 3, 2003 A little while ago, on a topic I don't remember, somebody gave me the idea for this script... But I never really take the time for it. Fed up by the mousing each time I want to send series of objects to a class or layer, I have a go at it. Since the idea come from the forum, and the subject has been coming back time to time, I'm quite happy to share the code. I would much appreciate to see interesting developments or ideas related to this script... is actually one of the interest of having a forum: share opinions and point of views, not only solve problems! He should work with all selected objects, and the function ForEachObject() could look inside groups or symbols with a different search criteria (I have a version that send specific object types thanks to another entry to the dialog). I've add a couple of options to follow the object (s) to the new layer/class, and to duplicate the selection. I set it up as a plug in with a shortcut and save me a lot of boring work across the screen. Must say thanks to the DialogBuilder developers... code: {/////////////////////////////////////////////////////////////// LayerClassT By: <Kiwi Dec 2003> Built with Dialog Builder 4 © 2001 Nemetschek North America. ///////////////////////////////////////////////////////////////} PROCEDURE LayerClassT; VAR dlogID,dlogResult,nl,nc,i : INTEGER; dialogIsOK,rsrcOK,dupl,go,dumm,OK : BOOLEAN; h,ho: HANDLE; Layerr,classr,currentL,currentC: STRING; Layers,Classes: DYNARRAY OF STRING; { dialog related subroutines } { Dialog definition function subroutine } FUNCTION Define_LayerClassT : INTEGER; VAR dialogID : INTEGER; BEGIN dialogID := CreateLayout('Layer/Class Transfer',True,'OK','Cancel'); CreatePulldownMenu(dialogID,10,25); CreatePulldownMenu(dialogID,20,25); CreateCheckBox(dialogID,30,'Follow objects'); CreateCheckBox(dialogID,40,'duplicate objects'); SetFirstLayoutItem(dialogID,10); SetBelowItem(dialogID,10,20,0,0); SetBelowItem(dialogID,20,30,0,0); SetBelowItem(dialogID,30,40,0,0); SetHelpString(1,'Accepts dialog data.'); SetHelpString(2,'Cancels operation without changes.'); SetHelpString(10,'Slect a layer to transfer your selected object'); SetHelpString(20,'Select the class you want your object transfer to.'); SetHelpString(30,'Go to the selected option with the actual visibility settings'); SetHelpString(40,'Select to duplicate your selected object'); Define_LayerClassT := dialogID; END; { get Layer names to dinarray Layers } Procedure GetLayers; BEGIN nl:=NumLayers; AlLOCATE Layers[1..nl]; h:=FLayer; For i:=1 TO nl DO BEGIN Layers:=GetLNAME(h); h:=NextLAyer(h); END; END; { get Class names to dinarray Classes } Procedure GetClasses; BEGIN nc:=ClassNum; AlLOCATE Classes[1..nc]; For i:=1 TO nc DO BEGIN Classes:=ClassList(i); END; END; { Change each obj settings } Procedure ChangeObject(ho:HANDLE); BEGIN h:=GetLayerByName(layerr); SetClass(ho,classr); dumm:=SetParent(ho,h); END; { Dialog driver function subroutine } PROCEDURE Drive_LayerClassT(VAR item:LONGINT; data:LONGINT); BEGIN CASE item OF SetupDialogC:BEGIN GetLayers; h:=ActLayer; CurrentL:=GetLNAme(h); FOR i:=1 to nl DO BEGIN InsertChoice(10,i,Layers); IF Layers=CurrentL THEN SELChoice(10,i,true); END; GetClasses; CurrentC:=ActiveClass; For i:=1 TO nc DO BEGIN InsertChoice(20,i,Classes); IF ClassList(i)=CurrentC THEN BEGIN SELChoice(20,i,true); END; END; OK:=TRUE; END; 1:BEGIN GetSelChoice(20,0,i,Classr); GetSelChoice(10,0,i,Layerr); dupl:=ItemSel(40); go:=ItemSel(30); END; END; END; { main body of script } BEGIN dlogID := Define_LayerClassT; dialogIsOK := VerifyLayout(dlogID); IF dialogIsOK THEN BEGIN dlogResult := RunLayoutDialog(dlogID,Drive_LayerClassT); END; IF dupl THEN duplicate(0,0); IF OK THEN ForEachObject(ChangeObject,SEL=true); IF go THEN BEGIN NameClass(Classr); Layer(layerr); END ELSE BEGIN Layer(CurrentL); NameClass(CurrentC); END; END; Run(LayerClassT);[/code] Quote Link to comment
B.Balemi Posted December 8, 2003 Share Posted December 8, 2003 Giday Kiwi Have tried your script .Did try to set up as plugin and as a script .I dont seem to be able to get it to read existing Layers & Classes .The Dialog returns empty .Is there any thing I am meant to be doing with this. Thanks for the contribution I agree with your sentiments about concepts & Ideas. Cheers Brendan Quote Link to comment
kiwi Posted December 8, 2003 Author Share Posted December 8, 2003 Hi Brendan, Witch software/OS are you using? Quote Link to comment
B.Balemi Posted December 8, 2003 Share Posted December 8, 2003 Sorry about that. Win Xp VWA10.5 2.66Mhz 1gig ram 128Video. Brendan Quote Link to comment
kiwi Posted December 8, 2003 Author Share Posted December 8, 2003 Yep! I try on XP and the dialog came empty??? I will try to identify the procedure that have a problem with XP and let you know. Cheers. Quote Link to comment
kiwi Posted December 8, 2003 Author Share Posted December 8, 2003 Got it! The assign integer for the pull down menus start at 0 and not at 1... for some reason on a mac still work, but not on a XP. once modify he looks like: Hope is find now.... code: {/////////////////////////////////////////////////////////////// LayerClassT By: <Kiwi Dec 2003> Built with Dialog Builder 4 © 2001 Nemetschek North America. ///////////////////////////////////////////////////////////////} PROCEDURE LayerClassT; VAR dlogID,dlogResult,nl,nc,i : INTEGER; dialogIsOK,rsrcOK,dupl,go,dumm,OK : BOOLEAN; h,ho: HANDLE; Layerr,classr,currentL,currentC: STRING; Layers,Classes: DYNARRAY OF STRING; { dialog related subroutines } { Dialog definition function subroutine } FUNCTION Define_LayerClassT : INTEGER; VAR dialogID : INTEGER; BEGIN dialogID := CreateLayout('Layer/Class Transfer',True,'OK','Cancel'); CreatePulldownMenu(dialogID,10,25); CreatePulldownMenu(dialogID,20,25); CreateCheckBox(dialogID,30,'Follow objects'); CreateCheckBox(dialogID,40,'duplicate objects'); SetFirstLayoutItem(dialogID,10); SetBelowItem(dialogID,10,20,0,0); SetBelowItem(dialogID,20,30,0,0); SetBelowItem(dialogID,30,40,0,0); SetHelpString(1,'Accepts dialog data.'); SetHelpString(2,'Cancels operation without changes.'); SetHelpString(10,'Slect a layer to transfer your selected object'); SetHelpString(20,'Select the class you want your object transfer to.'); SetHelpString(30,'Go to the selected option with the actual visibility settings'); SetHelpString(40,'Select to duplicate your selected object'); Define_LayerClassT := dialogID; END; { get Layer names to dinarray Layers } Procedure GetLayers; BEGIN nl:=NumLayers; AlLOCATE Layers[1..nl]; h:=FLayer; For i:=1 TO nl DO BEGIN Layers:=GetLNAME(h); h:=NextLAyer(h); END; END; { get Class names to dinarray Classes } Procedure GetClasses; BEGIN nc:=ClassNum; AlLOCATE Classes[1..nc]; For i:=1 TO nc DO BEGIN Classes:=ClassList(i); END; END; { Change each obj settings } Procedure ChangeObject(ho:HANDLE); BEGIN h:=GetLayerByName(layerr); SetClass(ho,classr); dumm:=SetParent(ho,h); END; { Dialog driver function subroutine } PROCEDURE Drive_LayerClassT(VAR item:LONGINT; data:LONGINT); BEGIN CASE item OF SetupDialogC:BEGIN GetLayers; h:=ActLayer; CurrentL:=GetLNAme(h); FOR i:=1 to nl DO BEGIN InsertChoice(10,i-1,Layers); IF Layers=CurrentL THEN SELChoice(10,i,true); END; GetClasses; CurrentC:=ActiveClass; For i:=1 TO nc DO BEGIN InsertChoice(20,i-1,Classes); IF ClassList(i)=CurrentC THEN BEGIN SELChoice(20,i,true); END; END; OK:=TRUE; END; 1:BEGIN GetSelChoice(20,0,i,Classr); GetSelChoice(10,0,i,Layerr); dupl:=ItemSel(40); go:=ItemSel(30); END; END; END; { main body of script } BEGIN dlogID := Define_LayerClassT; dialogIsOK := VerifyLayout(dlogID); IF dialogIsOK THEN BEGIN dlogResult := RunLayoutDialog(dlogID,Drive_LayerClassT); END; IF dupl THEN duplicate(0,0); IF OK THEN ForEachObject(ChangeObject,SEL=true); IF go THEN BEGIN NameClass(Classr); Layer(layerr); END ELSE BEGIN Layer(CurrentL); NameClass(CurrentC); END; END; Run(LayerClassT); [/code] Quote Link to comment
B.Balemi Posted December 10, 2003 Share Posted December 10, 2003 Gidday Kiwi Got it .Dont know how u worked that out so quick. Runnig as a script it works fine . Just question on dialog builder.Have tried it with VWA9.5 but not in 10.Is it availiable for 10.5. Havent seen it at NNA anywhere?. I'll see how many times can use this in the next week. Cheers cool tool. Brendan Quote Link to comment
kiwi Posted December 10, 2003 Author Share Posted December 10, 2003 I use dialog builder 4.0b4: the plugins work find on 10.5, just drop them on the plugins folder, and set the workspace. The debugger tells you if anything is not right, and on this case the procedures reading layers and classes work find (you can see the strings being assign), then could only be something related to the pull down menus and the way I assign the sting values. This debugger is a wonderful think. Let's hope we will have soon a real script editor with colors, scrolling and enable us to work with too or more scripts open (like BBedit but with compile and debug). Quote Link to comment
David Aynardi Posted December 12, 2004 Share Posted December 12, 2004 I've tried this script, it works, but I have a question. What is the line "1:BEGIN " (about 20 lines above the end?). I've looked but not been able to locate this construction in the vectorScript documentation. Quote Link to comment
MullinRJ Posted December 13, 2004 Share Posted December 13, 2004 David, It is part of a CASE statement in the Drive_LayerClassT procedure. "1" is the item number returned when OK button is pressed. Raymond 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.