WhoCanDo Posted April 12, 2019 Share Posted April 12, 2019 (edited) Hi, Can anyone explain why this is not working please? I want to use PP= with ForEachObject, but the test below indicates that (PP = Line_Style) doesn't work when the Line_Style is changed to a "Line Type" (Dotted, etc.) procedure test; var Line_Index : longint; begin ClrMessage; Line_Index := GetLSN (FSActLayer); Message (Line_Index); Wait (2); DSelectAll; SelectObj ((PP = Line_Index)); Message (GetLSN (FSActLayer), ' ', Line_Index); { ForEachObject (Do_This, ((T = Line) & (PP = Line_Index))); } end; run (test); Edited April 12, 2019 by WhoCanDo added - when the Line_Style is changed to a "Line Type" (Dotted, etc.) Quote Link to comment
JBenghiat Posted April 12, 2019 Share Posted April 12, 2019 PP is for pen pattern. What you want is LT, which takes the name of the line style. Using the criteria can be useful to get the syntax correct. Criteria can also be finicky with variables. You often need to pass the entire criteria as a string with escaped quotation marks around any string values. e.g.: crit := Concat('((T = Line) & (PP = ''', Line_Index, ''')))'); FEO( Do_This, crit); You can also concat Chr({ADCII_CODE_FOR_SINGLE_QUOTE}) instead of using the 'x3, but I don't have that off the top of my head. Quote Link to comment
WhoCanDo Posted April 12, 2019 Author Share Posted April 12, 2019 Thanks JB, This partly works. For SelectObj it works, but for ForEachObject it doesn't. I have had to use ForEachObject without PP and then check each "h" with "if (GetLSN (h) <> Line_Index) then" before running the code. I still think there is a bug with ForEachObject (Do_This, ((T = Line) & (PP = Line_Index))); not recognising the PP Quote Link to comment
Pat Stanford Posted April 12, 2019 Share Posted April 12, 2019 You have to declare a sub procedure (or sub function I can never remember which is used for ForEachObject and which for the FEOInList) and use that as part of the procedure call. Try: procedure test; var Line_Index : longint; Procedure Do_This; Begin SelectObj ((PP = Line_Index)); Message (GetLSN (FSActLayer), ' ', Line_Index); End; begin ClrMessage; Line_Index := GetLSN (FSActLayer); Message (Line_Index); Wait (2); DSelectAll; {SelectObj ((PP = Line_Index)); Message (GetLSN (FSActLayer), ' ', Line_Index); } ForEachObject (Do_This, ((T = Line) & (PP = Line_Index))); end; run (test); Too late for testing tonight. HTH Quote Link to comment
WhoCanDo Posted April 12, 2019 Author Share Posted April 12, 2019 Hi Pat, When you get back, try this with a line that has Line Type "Circles" or anything but "Solid" or "Pattern". It won't work. procedure test; var Line_Index : longint; Procedure Do_This (h : handle); Begin SelectObj ((PP = Line_Index)); Message (GetLSN (h), ' ', Line_Index); End; begin ClrMessage; Line_Index := GetLSN (FSActLayer); Message (Line_Index); Wait (2); DSelectAll; ForEachObject (Do_This, ((T = Line) & (PP = Line_Index))); end; run (test); Quote Link to comment
Pat Stanford Posted April 12, 2019 Share Posted April 12, 2019 Take a look at this version. It selects all of the lines in the file with the same LineStyle as the first selected object on the layer. procedure test; var Line_Index : longint; LineStyleName : String; ListID: longint; ListItems: LongInt; Procedure Do_This (H1 : handle); Begin SetSelect(H1); RedrawAll; Message (GetLSN (h1), ' ', Line_Index); Wait(1); End; begin ClrMessage; Line_Index := GetLSN (FSActLayer); LineStyleName :=GetDashLineTypeName(Line_Index); DSelectAll; ForEachObject (Do_This, ((T = Line) & (LT = LineStyleName))); end; run (test); I had to do some digging to realize the GetDashLineTypeName was the key to getting the LineStyleName so the criteria will work properly. Quote Link to comment
WhoCanDo Posted April 14, 2019 Author Share Posted April 14, 2019 I think this will work 😃 Interestingly, JB mentioned the LT option but it's not in the Appendix "Attribute Criteria" and therefore I thought it was a typo when his eg. used PP again. Sorry. Quote Link to comment
Pat Stanford Posted April 15, 2019 Share Posted April 15, 2019 @JBenghiat is rarely wrong 😉 I think that sometimes both he and I go a little too fast in trying to help and sometimes answer a different question than is actually being asked. But if you are persistent we usually figure it out and some up with a working solution. If you don't care about seeing each line select in turn, you can delete the Message and Wait statements and move the RedrawAll statement to just before the last End statement and the script will run much faster. 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.