Sam Jones Posted November 27, 2021 Share Posted November 27, 2021 I can create a line type choice list box with the "CreateLineStylePopup" VS procedure. I would like to set the initial selection With the "SetLineWeightChoice(dialog, kLineWeightMenu, #)" command. First, when I set the "#" to "2", it does not select the 2nd or 3rd (0 based) item in the line type list. So, what goes where the "#" is. Second, the line type I actually want to set I only know by name, "ISO-08 Long Dashed Short Dashed", and it comes from the VW application resources. I don't mind polling a list to find that line type, but what list? Once I find the named resource, how do I specify that line type to be the default selection in the menu. I was hoping this would be easy. It probably is, but the answer is arcane knowledge. Quote Link to comment
Jesse Cogswell Posted November 27, 2021 Share Posted November 27, 2021 (edited) Sam, The SetLineWeightChoice procedure is looking for the actual line weight value in mils, not the indexed choice of the pop-up. As for the line type, you would use SetLineTypeChoice with a LONGINT of the line type as the third argument. To find the internal index of your line type, you would use Name2Index('ISO-08 Long Dashed Short Dashed'). But also keep in mind that this would only work if that particular line type is already in the drawing (otherwise Name2Index will return 0). So you could do a little check with: IF(GetObject('ISO-08 Long Dashed Short Dashed')=NIL) THEN BEGIN resList:=BuildResourceList(96,14,'Attributes - Line Types',numLineTypes); FOR i:=1 TO numLineTypes DO IF(GetNameFromResourceList(resList,i)='ISO-08 Long Dashed Short Dashed') THEN h:=ImportResourceToCurrentFile(resList,i); END; This will import the line type as defined by the Vectorworks defaults file. Also keep in mind that SetLineTypeChoice may be looking for a negative value, so if you aren't getting the results that you want, try making the result of Name2Index negative, at least that's the case with SetLSN. Edited November 28, 2021 by Jesse Cogswell Quote Link to comment
Sam Jones Posted November 28, 2021 Author Share Posted November 28, 2021 Thank you Jesse. You have answered many questions; some unasked but should have been. Quote Link to comment
MullinRJ Posted November 28, 2021 Share Posted November 28, 2021 Sam, After much wrong guessing, it comes back to the simple things. Ha, "simple"!!! The list you want to interrogate is the Name List, though you don't have to do it manually, unless you want to. Use Name2Index() to find the index of a LineType name that's in the name list, then negate that index to set the LineType index in SetLineTypeChoice(), not SetLineWeightChoice(). Here's an example script. LineStyle menu example.txt Raymond Quote Link to comment
Sam Jones Posted November 28, 2021 Author Share Posted November 28, 2021 (edited) "SetLineWeightChoice()" It was a sloppy cut and paste job. I was always referring to "SetLineTypeChoice()" Critical things I needed to find out. 1. "Name2Index('ISO-08 Long Dashed Short Dashed')" would find the index I needed for SetLineTypeChoice() 2. In the expression, resList:=BuildResourceList(96,14,'Attributes - Line Types',numLineTypes); The values of "96" (type), "14" (default folder), and 'Attributes - Line Types' (subfolder name) were the values I needed to build the resource list. 3. That I might need to use the negative folder number. When I go back, and look at the appendix, that those were the values needed seems so obvious to be embarrassing. It would be best if I worked harder to investigate the VS functions that I do not use often, but which become critical for certain functionality. I could do that, or I could come here and benefit from the good graces of those that peruse this list. I will try to do more of the former, but I will see you all next time. It's kind of like copying a friends homework. It's a little embarrassing, but the dog ate my homework. Thanks all. Edited November 28, 2021 by Sam Jones added a clause 1 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.