Jump to content

Pat Stanford

Moderator
  • Posts

    12,626
  • Joined

  • Last visited

Everything posted by Pat Stanford

  1. And yes, the H1 definition is just a leftover from something else I was thinking of but never implemented. It can definitely be deleted.
  2. I don't think you can use IN the way you want to use it. Take a look at this one. I have left my debugging messages and wait statements in so you can see how it runs. I made a Function that will check and see if a record of a given name is attached to an object. This should probably be built-in, but is not as far as I know. It is probably possible to get rid of the EndFlag and do the check in a single While statement, but my head exploded trying to figure it out and I took the cheaters way. Actually this is probably much cleaner to read later when you need to go back to this in six months. I read a quote somewhere one time that by definition it is harder to debug a program than to write it. Therefore if you write a program as cleverly as you can, by definition, you are not clever enough to debug it. Procedure Test; Var ParentSymbol:Handle; ChildSymbol:Handle; SymDefHandle:Handle; NumberOfRecords:Integer; SymName:String; EndFlag:Boolean; {********* Function to test if a record is attached to an object by the Record Name ************} Function IsRecordAttached(ObjectHand : Handle; RecName : String) : Boolean; var ThisRecName:String; NumberOfRecords:Integer; ThisRecordNumber:Integer; Begin Message(Date(2,2),' Beginning of IsRecordAttached'); Wait(20); IsRecordAttached:=False; NumberOfRecords:=NumRecords(ObjectHand); Message(Date(2,2),' NumberofRecords ',NumberOfRecords); Wait(20); For ThisRecordNumber := 1 to NumberOfRecords Do Begin ThisRecName:=GetName(GetRecord(ObjectHand,ThisRecordNumber)); If ThisRecName = RecName then IsRecordAttached:=True; Message(Date(2,2),' ThisRecName ',ThisRecName); Wait(20); End; End; {********* Begingin of the main program *************} Begin ParentSymbol:=FSActLayer; SymDefHandle:=(GetObject(GetSymName(ParentSymbol))); ChildSymbol:=FInSymDef(SymDefHandle); EndFlag:=False; While ((EndFlag = False) and (ChildSymbol <> Nil)) Do Begin Message(Date(2,2),' ',GetType(ChildSymbol)); Wait(20); If ( (GetType(ChildSymbol)=15) AND (IsRecordAttached(ChildSymbol,'MyRecord')) ) Then Begin EndFlag:=True; End Else Begin ChildSymbol:=NextObj(ChildSymbol); End; End; SetRField(ChildSymbol, 'MyRecord', 'MyName', GetRField(ParentSymbol, 'MyRecord', 'MyName')); SetRField(ChildSymbol, 'MyRecord', 'MyNumber', GetRField(ParentSymbol, 'MyRecord', 'MyNumber')); Message(Date(2,2),' ', GetTypeN(ChildSymbol), ' ', GetSymName(ChildSymbol)); End; Run(Test);
  3. I tried to access a child inside a Symbol Instance instead of a Symbol Def, but I could not get anything.
  4. Here is an outline of how to do the handle traverse. I created a file with a record format named MyRecord with two fields, MyNumber and MyName. If you Attache Text To Record on the child symbol and attached the record to the parent, it will show up inside the parent when you run the script. Change the data on the parent and rerun the script and you will see the update happen. Procedure Test; Var ParentHandle:Handle; ChildHandle:Handle; SymDefHandle:Handle; H1:Handle; SymName:String; Begin ParentHandle:=FSActLayer; SymDefHandle:=(GetObject(GetSymName(ParentHandle))); ChildHandle:=FInSymDef(SymDefHandle); While GetType(ChildHandle) <> 15 do Begin ChildHandle := NextObj(ChildHandle); End; SetRField(ChildHandle, 'MyFormat', 'MyName', GetRField(ParentHandle, 'MyFormat', 'MyName')); SetRField(ChildHandle, 'MyFormat', 'MyNumber', GetRField(ParentHandle, 'MyFormat', 'MyNumber')); Message(Date(2,2),' ', GetType(ChildHandle), ' ', ChildHandle); End; Run(Test);
  5. You could select the ParentSymbol instance in the drawing and get a handle to that. Then use that info to get a handle to the symbol definition then use FInSymbol to get a handle to the first object in the symbol definition. Step through the list until you find an object of Type Symbol. As long as the ParentSymbol only contains a single ChildSymbol this should be a relatively easy way to get handles to both objects. If you are interested in working on this, let me know and I can probably get you a better outline of how to do the steps necessary to find the ChildSymbol.
  6. You never assign values to the handles for ChildSymbol and ParentSymbol, so there is no way for the script to know what objects you are trying to get and set information from. Adding something like: ChildSymbol:=FSActLayer; ParentSymbol:=GetParent(ChildSymbol); Should do it, but only if you can select the ChildSymbol before you run the script. If not, you will need to use some other method to get a handle to the ChildSymbol.
  7. (Raising hand and jumping up and down in seat), Me, Me, Me. I know, I know!!! This is ancient history and stems from the original Mac OS (maybe System 4, maybe earlier, I can't remember what was running when MiniCAD was released). Rich Diehl, when he mapped the shortcuts mapped them by physical position rather than by some obscure relative meaning. The tool pallette left hand column was Move (hand) [C] Selection [V] Zoom In [X] Zoom Out [Z] Text [1] Line [2] Arc [3] Rectangle [4] This kept all of the shortcuts together and did not require understanding a (possibly) obscure mnemonic to remember (like L for line, Z for zoom, etc.) This is also where the shortcuts for the Mode bar came from (U,I,O,P,{.}) for each of the six possible groups. For the constrains palette, set is up as two wide four tall and you get ASDF down the left column and QWER down the right. Most of these shortcuts still exist in the current default workspaces, though a few have been changed over the years as different workflows and input devices have become more popular. The hardest one for me to get used to was the Hand tool which shifted from C to J. A double click on the C key used to generate a screen refresh. Very important when redraws where much slower. It took me about three versions to get used to is being the H key. And now I hardly ever even need that function.
  8. Check out Appendix F of the Vectorscript Appendices, specifically 57, 58 and 82-85. Most of these are GetPrefInt, with a couple being GetPrefReal. Also GetPrefString(100); will get you the active font name.
  9. Take a look at the example script I posted to the Resource Sharing - Vectorscript forum. https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=208188Post208188
  10. This is an example script that shows how to use the ForEachObject call to find certain Lighting Devices and rotate, move and change field values. Please use as you see fit. Procedure SetLightParams; {An example script showing how to rotate, move and set field values of a lighting object} {February 19, 2015} {© 2015, Patrick Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} Var ThisLight: Handle; Procedure ActOn(ThisObject:Handle); {ThisObject is a handle to the object passes by ForEachObject} Var X1,Y1,R1 : Real; Begin {Set the Symbol Name field to desired value} SetRField(ThisObject,'Lighting Device','Symbol Name','Conventional'); {Get the current rotation of the object. GetSymRot works on PIOs as well as symbols} R1:=GetSymRot(ThisObject); {Get the current location of the object. GetSymLoc also works with PIOs as well as symbols} GetSymLoc(ThisObject,X1,Y1); {Set Rotation to Zero by rotating the negative of the current value} HRotate(ThisObject,X1,Y1,-R1); {Move to a Y value of zero by moving by negative of current Y value} HMove(ThisObject,0,-Y1); End; Begin ForEachObject(ActOn,(((PON='Lighting Device') & ('Lighting Device'.'Device Type'='Light')))); {ForEachObject will run the procedure named ActON one for each Lighting Device of type Light} End; Run(SetLightParams);
  11. The other option is to zoom in to show only the part of the drawing you want to see and use the Print Current View Only check box in the print dialog. It will automatically scale up or down to match the paper size, but you will have to change the Page Setup to use the paper size you want. You probably want to Save the file first, change the paper size, Print, then Revert to Saved. Of even better just use a temporary Sheet Layer and Viewport.
  12. No actually we can't assume you know what you want. Since you came to the board (which you never do) asking for free help to solve a problem that you have not defined adequately, we have to ask questions to avoid wasting our time. I know you said you would hire someone if necessary, but you are still asking for free help. Many times people come to the board and ask for something without realizing they are trying the hard way to do something simple. In your case, you asked for a script, but didn't bother to explain WHY you want a script. What about your workflow makes this something that needs to be scripted. It would probably take at least an hour of someones time to write and test the script you are asking for. If this was a one time problem with a single file that a would take 5 minutes to do manually is not worth it. yes, we need to ask more about what you want to do. If this is rude, then I apologize, but I think you caught me on a bad day. You comment about not wanting to be rude struck me as very rude. If you want help make it as easy for everyone as possible and give the reason for what you are asking for, not just the desired result. To many times I have jumped to provide a solution for someone only to find out that they did not define the problem properly and that my solution did not solve their real problem. I try not to do that, hence always questions first.
  13. There is also a similar field for Doors. ='Door'.'NGA2'
  14. If you want the Name you typed into the Data Pane of the OIP to show in a worksheet, the formula is =N Layer is =L
  15. Create a worksheet with a database row. The criteria for the database will be to isolate the parts you want the volume of. You may want to use multiple database rows, one word walls, one for slabs, one for roofs, etc. The formula to get you the volume of the object is =VOLUME It appears that for Walls, the volume excludes the space taken up by doors and windows. There are also specific functions available to get more information about walls, roofs, etc, including: Wall Gross and Net Area, Roofs Heated and total Area, etc. In VW2015, with a worksheet open, go to the Worksheet Insert Menu and choose Function to see a list with brief explanations of all the data you can get from objects. You can also use a =record.field format to pull data from the PIO record (OIP information and more) of objects. See the thread at https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Main=41665&Number=207338#Post207338 for more information on a way to see all of the record.field information for a specific type of PIO.
  16. Someone finally posted a request for the inverse of this this, a script to replace a loci with a circle, so here it is. Procedure LociToCircle; {Replaces every Loci in a drawing with a Circle} {centered at the insertion point of the loci. Use with care after backing up} {the original drawing. Use at your own risk. Here there} {be dragons. No warranty expressed or implied. ;-) } {Adjust the Const Radius = 1' to a unit an size appropriate to the requirement} {All Circles created will use the default class, color, etc of the document.} {January 28, 2015} {July 15, 2011} {© 2011-2015, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} Const Radius = 1'; Var Hand1, Hand2 :Handle; Int1, Int2 :Integer; Procedure DoAction(Hand3:Handle); Var X1, Y1 : Real; Begin Get2DPt(Hand3, 1, X1, Y1); ArcByCenter(X1,Y1, Radius,0,360); DelObject(Hand3); End; Begin ForEachObject(DoAction,((T=LOCUS))); End; Run(LociToCircle);
  17. My personal opinion is that you are best to place an instance of the PIO type you are working with in a separate file and then run the script from there. Since the worksheet the script creates has to be open to be able to cut and paste the record.field values, I find that it is a very large window and takes up a lot of drawing space. For me it is easier to swap between files that to swap between worksheets. On the Mac, you can use Command-~ (command tilde) to switch between windows of the current application.
  18. You can also use the script from the Vectorscript Resource Share forum to create a worksheet showing the fields available for a PIO. It will tell you the type of object and give you a "cut & paste able" version to use in other worksheets. https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=108487#Post108487
  19. In VW2015 a search of the online help for "Worksheet Functions" appears to show 60+ functions. I have not done a direct comparison to the pulldown, but this should be most of them. Couple these with the ="Record"."Field" format to get information from objects in the drawing and you have all of the power of worksheets. The Help also refers you to the developer docs if you need more information on criteria.
  20. What formula are you using to in the worksheet you are showing? =('FramingMember'.'LineLengthReal') Appears to give the length field shown in the OIP.
  21. It depends on the intended use. If this is really a one time only event and you don't have to worry about the names changing in the future, then the worksheet is absolutely perfect and brilliant. You can set it up and do it in way less than an hour even if you have never worked with worksheets before. The script will be more robust and better for things that will change more often, but even with all the scripts I have written to do similar things, I would estimate that a fully robust script with error checking etc. would take nearly 8 hours to program and test. Different Horses for Different Courses.
  22. I just did a test and I would bet if you file this as a bug it will come back as "Working as Designed". I don't necessarily think the design is correct and perhaps you want to submit a feature request to change the way it works. Object 1 - Set in Attributes Palette (AP) for Fill to Use Class Style Object 2 - Set in AP for fill to a fixed pattern with the Fore and Back colors set to Use Class Color Object 3 - Set in AP for fill to a fixed pattern with the For and Back colors set to fixed colors. In a viewport when I use the Class Overrides I get the following: Object 1 - Will take both pattern and colors from the Edit Class(es) dialog box. Object 2 - Will take the colors from the Edit Class(es) dialog box. Object 3 - Will not take pattern or colors from the Edit Class(es) dialog box This seems completely logical to me, but maybe I am missing something. As I read your post of 9:29AM (three above), you say you have everything in the Attributes Palette set to By Class, but then later you say you don't have the Pattern colors set by class. Which is it? The Viewport overrides can not effect anything that is not set to By Class (or Use Class Color) in the Attributes Palette. I also just checked the command under the disclosure triangle at the bottom of the Attributes Palette. If you use the Make All Attributes By Class, it sets everything, including the pattern colors set to use by class. Based on the terminology you are using (model space instead of design layer), it appears you are coming to VW from another program. Are you seeing something that is just different from what you are used to? If I am missing something, please try and give us a better description of what you are seeing. Maybe make a simple file that shows the problem and upload it here for us to look at. If there is a bug we want to get it reported and fixed, but we don't seem to be seeing the same things.
  23. I don't know of any direct way to do this. Since the Symbol Name is not part of an accessible record format, you can't use it directly to Link Text to Record. The only suggestion I can make is to add a field to your existing record format (or add an additional record format) and then use a script to add that Record to the Symbol Definitions and copy the Symbol Name into the Field. If you decide to go this way, let me know and I can probably help you out. I have added Enhancement Requests for two ways to possibly accomplish this task. Hopefully they get added to future versions.
  24. You can't do this with a symbol, but you could make a Plug-In Object (PIO). A PIO has record fields attached. By editing these in either the Object Info Palette (OIP) or via a worksheet you can change the way the object draws. PIOs need to be created using either Vectorscript, Python or C (via the SDK). How complicated is your symbol? Can you post an image of what the symbol should look like and how it should change? You might find some of us here to help you create what you need.
×
×
  • Create New...