Jump to content

PeterT

Member
  • Posts

    593
  • Joined

  • Last visited

Everything posted by PeterT

  1. Musisback, You can use the ObjectVariableString call with the handle to the layer link object and an index value of 160: sourcelayerstring := GetObjectVariableString(layerlinkhandle,160); This function returns your source layer name as a string variable. The index value is listed in the VectorScript Appendix under Layer Link.
  2. What I am really trying to do is copy the annotations to the clipboard. I already have the handle to the annotations group using GetVPGroup(vphndl,2). The only way I know to do this is to select the objects and copy with DoMenuText, but selecting the annotations group seems to select the entire viewport, not just the annotations. I thought if I could get inside the annotations group I could then select just the annotations, but I cannot yet find a way to do this.
  3. Does anyone know of a way to edit a viewport annotation in a script, using DoMenuTextByName or otherwise, without invoking the Edit Viewport Dialog? Even having the handle to the annotation group, selecting the group, and choosing DMTBN for Group Navigation Chunk 2, it brings up the dialog and makes you select the Annotations radio button. Is there a preference selector or anything similar to preset the edit to annotations like you can do when double clicking a viewport? Or is there any way to get to the contextual menu choice for edit annotations through Vectorscript?
  4. Bruce, Have you checked out the Free Resources Nemetschek has posted on their website? They have a Getting Started tutorial for most of the industry series products, as well as Fundamentals: Free Resources There is also a link to some more comprehensive user guides that are written by third parties, but are not free: Guides & Publications
  5. Is it possible that LNewObj does not work because using CallTool temporarily exits the script to give user control of the tool then returns to the script, and by doing this, does not see the object as being created within the script? If you get rid of the CallTool from the script altogether, then LNewObj works fine: Procedure CustTool; VAR Name:STRING; Result:BOOLEAN; p1x,p1y,p2x,p2y:REAL; BEGIN PushAttrs; NameClass('NonPlot'); GetLine(p1x,p1y,p2x,p2y); MoveTo(p1x,p1y); LineTo(p2x,p2y); SetName(LNewObj,Date(2,2)); PopAttrs; END; Run(CustTool); Funny enough though, LObject also works in this case. I did not think LObject would work on the last object created during the script run. I thought until the script finished executing, it would find the last object created before the script run. Can anyone explain clearly the intricacies of LNewObj versus LObject? Every time I think I understand it, I don't.
  6. Charles, Yes, that is the way I am doing it now, and it works fine. Fortunately, I am only running the script on visible layers, and loaded the array with objects only on these layers, so with Layer Options set to show/snap/modify, a simple SelectAll gets all the objects I am working with.
  7. If I use GetPickObjectInfo, the other issue I will have to resolve is actually obtaining the coordinate location. I am needing this inside of a running subroutine, and all I have is a handle to the wall and a handle to a line that crosses the wall where the symbol is inserted. So I cannot use GetPt, and will have to find the intersection of the wall and line. I also have other cases where the line crosses the inserted symbol but not the wall, for example where the line is parallel to the wall but crosses an open door swing. If I GetType of the object here it still returns type 68 (wall), but I am not sure if GetPickObjectInfo will find the sub selectable object if it does not find the wall object at that point.
  8. I am initializing the index, and in the FEOIL I have the traversal options set to 0 (shallow) so that is not it. But I added Message(index); right after I load the array, and testing on the same file as yesterday, it returns 2,461, which seems more like it. So I reset the size of the array to 2500, and today, I am getting no error message. I do not know what was going on yesterday, but it seems O.K. now, so I have set it to a size of 10,000 which should cover any of our plans and I will lay the array to rest. Thanks for all the input. Now, to resolve the other remaining issues.
  9. I have my script generally working at this point, but there are a few areas I still need rewrite for complete functionality. But I am much closer to completion. As for the array, I was getting "index outside of array limit" errors at 1,000 elements, so I tried 5,000, then 10,000 then 20,000, still getting error. Finally I tried 30,000 and voila, no error. I am testing on only a moderately busy floor plan, so I do not know if 30,000 will be enough for all files. I may have to look into Dynamic Arrays, but I am already at close to 32K with a static array. Maybe someone can clarify the upper limits of these arrays a bit more. The funny thing is that in VW version 12.5 in the "About VectorWorks" splash it tells you how many objects are in your drawing, and how many on the active layer, but VW 2009 does not show this any more. My test file was converted from a 12.5 file though, and in 12.5 it tells me it has 2,609 objects in file, so I am curious why when loading the file's objects into the array in version 2009 I was getting index over limit errors at an array size of 20,000. I am also slightly skeptical that I have close to 30,000 objects in my file.
  10. Is there any way to get the handle of a PIO in wall or a symbol in wall by its location on the drawing? If I go to the location of a placed symbol or PIO in a wall and GetType of the object at that location it returns type 68 (wall) and not the type of the inserted item. Do I have to HUngroup the wall in order to get to the object? I was hoping to use SetParent to remove the object from the wall without having to explode the wall, but I cannot seem to get to the inserted object in the first place. Am I missing something simple here?
  11. Charles, thanks for the array examples, there is some good info in that thread. A couple of questions though. Is there a maximum limit to the size of a static array? I may have more than 1000 objects to load. Does it hurt to set up more storage locations in the array than you actually use? You certainly don't want too few. Once the array is set up and loaded, how would I go about selecting all objects not in the array? Would I select everything, then traverse the array to deselect those objects? DWorks, yes, the group thing was my original idea, but the multiple layer issue put a damper on that. I might still be able to do it though, by looping through the layers and grouping on each layer individually, but I think I will try working with arrays first.
  12. Josh, Thanks for the idea, but after testing Split2DObjectByLine with ForEachObjectInLayer, there are too many problems to use this. For one thing, it only seems to split polygons, and will not split line or wall objects which make up 75% of my drawing. Even for polygons I get odd results when using CreateDuplicateObject from the resulthandle. The annotated function reference mentions some limitations of this call. I think maybe it should be called Split2DPolyByLine. Unfortunately, I think I will have to stick with the DMTBN trim call.
  13. I guess I was hoping there was an easy way to get handles to all the new objects without to that point having to process each object on each layer individually. So far my script has low overhead as everything is done to all objects at once. Although the objects are all on different layers and all in different classes, with layer options set to show/snap/modify, I can duplicate and move a set of specific objects with one call, deselect all, draw a cutting object, and trim all the objects with one call, and all the resulting objects remain on the appropriate layers, and in the appropriate classes. At this point I have done the bulk of the work without having to look at each object individually or traverse through any of the layers in the file. Also, to trim the objects, I must use use a DoMenuTextByName call, and there may be a significant number of objects processed, so I definitely do not want to call this more than once. So this is why I was trying to take the approach of loading the handles at the end of the script rather than along the way. But the Idea of building an array of objects before I do anything is intriguing. I have never used arrays before in my scripts and should probably look at that. Are there any examples of how I might load objects into an array? Thanks for the input.
  14. DWorks, Thanks for the input, but I am not sure I can do that. This is just part of a larger script that does a lot of work before it gets to this point. Many of the objects I want to process were created with a mass duplication of selected objects, other objects were created by trimming one or more objects into two or three parts each. And I am not sure what happens to the handle of an object when trimmed into three parts. Do you get the original handle and two new handles, or is the original handle deleted and you get three new handles, and which of the three parts would be the original handle if it is kept? To complicate it more, multiple objects might be trimmed all at the same time, so if I am trimming three objects into nine objects, how do I get the handles to all these objects? And if I use LNewObj and PrevObj how do I stop the loop after the newly trimmed objects are found when the last new object before the trim procedure might be one of the objects that was trimmed? So really, I want to get the handles to these objects after all the other work is done, and it would be very difficult to get their handles along the way. Also, I only want to select some of these newly created objects, not all of them, so I really need to first access a list of all the new objects, then perform a selection function a on just some of these objects.
  15. I am having trouble with a large script I am writing, and the trouble area involves document list handling. I am trying to process all objects newly created in the script, but these objects occur across multiple layers. I want to exclude processing any objects existing before the script runs. My thought was to get a handle to LObject at the beginning of the script which would be the last object created before the script run, and work up the object list until I got to LNewObj which would be the last object created during the script execution. I tried using ForEachObjecrtInList specifying the handle to LObject as the first object in the list, thinking it would work up the object list from there, but this seems to process even the objects created previous to the script running, perhaps because I am starting in the middle of the object list. The documentation for this says to specify a handle the the first item in the list. Does this mean the handle I give it defines the first item in the list, or that I have to start at the first object, FObject? Then I looked at ForEachObjectInLayer, but I am unclear as to what order the objects are processed using this, and could not figure out how to specify the starting and ending objects, or the subset of newly created objects. Next I tried setting up nested loops to go up or down through all the layers and work up or down the object list on each layer using NextObj or PrevObj. So I started with LNewObject and tried to work down the list until I got to the LObject. But this seems to fail when I get to a layer that does not contain the LNewObj, and nothing is processed on that layer. There does not seem to be a call for LNewObjInLayer. Also, LObject may, or may not, be on the same layer as LNewObject. Is there some way I can isolate the list of all new objects created during the script execution which occur on more than one layer? Is there a separate object list for each layer, or is there only one object list for the whole document? I could sure use more knowledge in this area. I am stumped. I can't find much documentation or many examples of this process. Can anyone shed some light here?
  16. One last note, I did find some documentation on the pickRadius in the Annotated Function Reference, but it still does not make a lot of sense to me. It appears my script is working because my title block is grouped. If I ungroup it though, there does not seem to be any real number I can enter as the pickRadius variable without some part of my title block disappearing at some level of zoom. I will just have to be sure the title block is grouped before running the script.
  17. Pat, I guess I could have figured out you meant GetPrefLongInt, but thanks for the correction. But the returned values are no less confusing than when using GetPrefInt. But setting the selection box size is moot when using ForEachObjectAtPoint. Rewriting my script to use this call fixes the problem. ForEachObjectAtPoint would allow me to process only unlocked objects too, but that does not seem necessary as using this call a point is a point, and only objects at the exact point location seem to be found. I tried this at all levels of zoom, and at layers of all different sales, with or without a date object present, and it never deletes the title block. The funny thing is, in ForEachObjectAtPoint, the last variable is REAL variable called PickRadius. I would have thought this would affect the size of the selection area, but I ran my script with this set to 0, 1, or 1000, and it did not seem to make any difference. There is no documentation on this last variable, so perhaps it is a dummy variable for future use, or obsolete. Bottom line, my script now works as intended. Thanks for all the input.
  18. Thanks Pat, I will download the SDK an check out the Callbacks file. But as for the preference setting calls, I thought GetObjectVariableLongInt was for object properties. How would I use it to set application preferences? It requires an object handle. At some point I will test GetPt and ForEachObjectAtPoint for selection box size. Ramond, In my current script, turning off the snap constraints has no effect. It is not the size of the snapping area that is the issue, it is the size of the selection area, which is now adjustable in the interactive preferences. At 1:1 scale, and zoomed to 100%, with the selection box preference turned all the way to maximum, clicking on the drawing will select something almost 1/2" away on the diagonal. GetPickObjectInfo seems to pick the point using this setting. I will test GetPt and ForEachObjectAtPoint next. Thanks for the suggestions.
  19. Pat, Thanks for the selectors, they do return the values for the snap box and selection box sliders, but the returned values are sure not what I expected. The biggest box size has a value of 0, and the smallest a value of 5243, with all the values in between being seemingly random positive or negative four and five digit numbers. I sure would like to know where you got these undocumented preference selectors though, are they listed somewhere? As far as my script, the values don't specifically matter, as long as I can get them and set them, so I can do what I was hoping to do to improve my script. But as Miguel suggested, I am sure there is a better way to do what I am doing. I am using GetPickObjectInfo in my script to test a given point for an object and if found, to delete the object. I never realized in version 12.5 that GetPickObjectInfo still uses your snap or selection radius when testing the point. In my mind, a point is a point, not an area. When we upgraded to version 2009, with user controllable selection box size, I noticed my script was deleting unintended objects NEAR the specified point, especially if zoomed out when the script was run. I guess I have the selection box set to a larger size than whatever the default size was in version 12.5. I think I can improve my script by resetting the selection box size to the smallest size during script execution, then setting it back before exiting the script. But maybe this is not the best way. My script puts a date in the title block of my sheet or updates the date if one is already there. To update, it just deletes any found date and puts the new date there, but when zoomed out it seems to delete the entire title block if updating. I tried locking the title block, but VectorScript still seems to delete locked objects. I guess I could test the object type and only delete if text, but that still might delete other nearby text objects in the title block. Also, I would like to avoid naming the date object if possible. Is there a better way of checking a point for an object that does not use the snap radius and find nearby objects? Anyone have any ideas?
  20. Does anyone know how to get the Snap box or Selection box size in VectorScript? GetPrefInt(54) returns the Snap Radius, but I am not sure what that even is anymore in VW 2009, as the "radius" was replaced by the "box". And on my system GetPrefInt(54) always returns 5 no matter where the snap or selection box slider controls are. Anybody know if there are any new preference selectors for this?
  21. Yeah, I guess "Navigation" is not considered to be "Fundamental".
  22. Thanks Charles, I substituted in the PushAttrs and PopAttrs, and the script works fine now. I guess I had my brain so wrapped around understanding the event enabling that I over complicated the easy part of the script. This also shortens my code by 8 lines. Also, I guess I have never used push and pop for text, I have just used it for pen and fill attributes. I would still be interested in knowing why the other way was failing. I do not think Reset object would have done it as the object was drawing correctly. It was the document defaults that were failing. Maybe it had something to do with the compiler mode, or haven't I read something about plug-in objects regenerating twice? The script was clearly getting attributes that were not being set until after I got them, so the code must have been read twice by the compiler. This is an area in which I could certainly use more knowledge. Thanks again, Peter
  23. Hi All, I have a point object Plug-In (Event Enabled) that is simply a piece of text that is edited in a dialog by a cursor double click. This is my first dabble into event enabled scripting, so I am quite happy that for the most part, the object is working as intended. I have one problem though. I need the placed text object to have specific text settings such as Font, Size, Style, and Alignment. To accomplish this I am first collecting the text defaults, then changing the defaults before the object creation, then changing the text settings back to the original defaults after the object creation. I am doing all this in the Reset Event case of the script. It works correctly as far as creating the object with the correct text settings, but there seems to be a problem with re-setting the defaults back to their original values when done. Specifically, the default Style and Alignment are not returning to their original settings after the object is placed in the drawing. This is not a problem when double clicking on an existing object in the drawing and editing, it is only a problem on placing a new object in the drawing, which seems odd as I thought the same Reset Event occurs whether the object is placed or edited. I have tracked the issue down to the gathering of the default Style and Alignment, not the re-setting. I set up a message to return the default values being collected during the Reset Event, and when the object is placed, the message returns the Style and Alignment settings that are not set until after I collect them. But when the object is double clicked and edited the message shows that the correct default values are collected. Here is a snippit of my Reset Event: CASE theEvent OF kResetEventID: BEGIN {Gets default font settings and fill pattern} fontstr := GetPrefString(100); txtsize := GetDefaultTextSize; txtstyle := GetPrefInt(58); {these two text items do not correctly return default values when } txtjust := GetPrefInt(82); {object is placed, but return TextFace and TextJust that are set below} dfltfill := FFillPat; Message(fontstr,' ' ,txtsize,' ' ,txtstyle,' ' ,txtjust); {Sets default font settings and fill pattern for object creation} TextFont(GetFontID('Palatino')); TextSize(36); TextFace([bold]); TextJust(2); FillPat(0); {Draws object} shtnum := PSHEET; MoveTo(0,0); CreateText(shtnum); {Resets font settings and fill pattern back to original default values} TextFont(GetFontID(fontstr)); TextSize(txtsize); SetPrefInt(58,txtstyle); TextJust(txtjust); FillPat(dfltfill); END; One additional piece of information is that the default font and size do correctly return, and therefore are correctly reset, although they are also changed in the object along with the style and justification. I find the text functions in VectorScript confusing enough, but this one has me stumped. Does anyone have any ideas what is going on here?
  24. Have you tried updating the Viewport on the OIP after updating the reference?
  25. Here's a few additional thoughts. You can attach a VectorScript to a Saved View such that the script runs each time you choose that View. You cannot do this with Sheet Layers, but what you can do is save a view of your Sheet Layer such that when you choose your sheet your script runs. We use this a lot in our office. You can attach a script that switches to Black and White, or one that dates you sheet, or one that changes the attributes of your drawing content, the possibilities are endless. Also, Saved Views set your class and design layer visibilities when you choose them. This is invaluable to us, as we do our work on design layers, and when I go to a design layer to work on it, I usually want to see all layers and classes that are visible on the final sheet. If you navigate to a design layer through editing a viewport, you only see the the design layers that are visible within that viewport. I might have six viewports on the same sheet, all using different layers and classes, and when I when I go to the design layer in one of the viewports, all of the design layers in the other five viewports become invisible. By saving a view of your sheet, you can change the visibilities of your design layers when you go to your sheet layer. Then you can go to your design layers just like the old days, by scrolling down the layer list to the appropriate layer, and voila, all the design layers in your entire sheet are visible, not just the ones in one particular viewport.
×
×
  • Create New...