Jump to content

MullinRJ

Member
  • Posts

    2,013
  • Joined

  • Last visited

Everything posted by MullinRJ

  1. When I execute GetCurrentPlanarRefID on a design layer it returns "1" if I am drawing on the Layer Plane or any 3D Working Plane I set. If I change to the Screen Plane it returns '0'. Inside a symbol's 2D side it returns "0", and on the 3D side it returns "-1". Inside an Extrude it returns "-1". On a Sheet Layer it returns "0". I understand the Layer Plane is refID = 1, and the Screen Plane is refID = 0, while Working Planes have other integer values for the refID. I cannot get it to recognize any Working Plane I set in a drawing. Am I missing something, or does this command not do anything I can use? The documentation says: "Return the current plane ref ID. This could be any plane: a working plane, screen plane (0), ground plane of a container, or any arbitrary plane." If anyone has been able to use this command to identify planes other than the Screen or Layer planes, I would really like to hear from you. TIA, Raymond
  2. Hi Jayme, It may not be the answer you wanted, but it sounds like you are on the right path. Another thing to evaluate, how fast does CopySymbol() work if your reference file is open all the time? I don't know what your system configuration is, but consider opening the reference file when you launch VW and leave it open for the drafting session. If it works, and your system doesn't slow down, it may keep you from splitting the symbol file right now. Just a thought. All the best, Raymond
  3. Hello @Jayme McColgan, First question, did you convert your reference file to VW 2024 format? I would expect this to give you the best chance for success. If you have converted it and your code still runs slowly, I would copy some symbols into a much smaller temporary file and try your code again. If it's still slow, then it's not the reference file's size. Perhaps it's a drive, or network problem. Try copying the file to your computer and try again. Does it run faster when the file is local? If pulling symbols from a much smaller file speeds things up significantly, then I would find a way to partition your non-partitionable file into two or more smaller files. Split it alphabetically and you can easily code your symbol calls to address the correct source file using the symbol's name to determine the source file. Of course there are many ways to approach the overall problem. I hope you find one that works well for you. Raymond
  4. Hello, @halfcoupler. Your script seems to work in VW 2024, and 2023. If only one object is selected the OIP updates. If multiple objects are selected, then, yes, the OIP does not update the Class popup menu and displays the old setting. If you have multiple objects selected, do you want to apply the new class name to all of the selected objects? If so, try this script: PROCEDURE Set_A_Class; { Change the class name of all selected objects that are on editable layers. } CONST kNewClass = 'MyClass-Pink_Flamingo'; function ApplyClass(H :Handle) :Boolean; Begin SetClass(H, kNewClass); SetSelect(H); { Resets OIP } End; BEGIN ForEachObjectInLayer(ApplyClass, 3, 0, 4); { Visible/Selected, Shallow, Editable } SysBeep; { make noise when done } END; RUN(Set_A_Class); To assign other class names, change the constant "kNewClass". The ForeEachObjectInLayer() function loops through every object that meets the conditions specified by the three numbers shown in the call. In this case it looks for Visible and Selected objects (1+2), does not go inside Groups or other containers, or Shallow (0), and works across Editable Layers (4). If you need more information on this and similar ForEachObject functions, check out the Developer Wiki and Function Reference Links in the blue bar shown at the top of this page. HTH, Raymond
  5. @Pat Stanford, It's this button: I didn't know either until I floated the cursor across the icons looking for a clue. Luckily one popped up. Raymond
  6. @Juliensv, Are you wanting the value to use in a worksheet, or just in a script? For accessing the length in a script, here's an example that shows the exact length in document units but w/o the units string displayed. PROCEDURE xxx; { Show the length of a selected dimension object. } { 10 Nov 2023 - Raymond J Mullin } VAR H :Handle; B :Boolean; P1, P2 :Vector; BEGIN H := FSActLayer; if (GetTypeN(H) = 63) then begin { Dimension object } B := GetObjectVariablePoint(H, 13, P1.x, P1.y, P1.z); { point 1 } B := GetObjectVariablePoint(H, 14, P2.x, P2.y, P2.z); { point 2 } AlrtDialog(concat('Dimension Length = ', Norm(P2-P1))); { display length } end { if } else AlrtDialog('Selected object is not a DIMENSION object.'); END; Run(xxx); If you want to control the number of decimals displayed in the answer, use the Num2Str() function around the Norm() function, or if you want the answer formatted using the current document units, use the Num2StrF() function. Lastly, if you want the answer for use in a Worksheet function, a some lines will need to be added and removed. HTH, Raymond
  7. Hello Peter, Reshaper will let you set the 3D view relative to the selected 3D Object. Top, Front, Left, Iso views top and bottom. And you can rotate the view around the primary axes relative to your current view. I believe you have a copy of Reshaper. Let me know if it needs updating. Raymond
  8. Also, FWIW, Entered in Group which is also listed as 6756 might be 6755 as defined on the next line: varGetEnteredGroupHandle = 6755, // Handle read - Get the Handle of the current opened for edit group in VW document. BUT, is it? I have not used this pref yet, so I can't tell you exactly how it's supposed to work, but it looks like GetPref(6755) returns returns FALSE if you are on a Design or Sheet Layer, and TRUE if you are inside a GROUP, a Symbol, a Polyline Profile, an Extrude, i.e., inside a container object – BUT – if you enter a GROUP that's inside a Symbol Definition, it returns FALSE. Not sure I understand this last part. And here if gets weirder, if you are inside a Group inside another Group inside a Symbol Def, it returns TRUE. It's Alice Through the Looking Glass trying to find Waldo. This is all off the cuff, and doesn't answer anybody's question at the moment, so enjoy the rabbit hole, all ye who enter. Raymond
  9. God bless Carlotta !!! 😇
  10. Yes, I would build a list of class names and their replacements, then iterate through the list. There may be a more elegant approach, but none comes to mind. There are many ways to build the list, and that may be where you achieve elegance. You'll want to restructure the example program to make the main loop into a procedure that you call for each item in your list, passing it the new and old class names. ForEachObjectInList() will do most of the heavy lifting. If you have any questions about the existing example, please write back. All the best, Raymond
  11. Hi @Sam Jones, It is true, Python has its quirks, but so does the VS language. You've learned many of them over the years. In all, Python has more upsides than down. As you are very comfortable with VS, I wouldn't recommend moving for the sake of moving. Unless you you need something that Python can offer, like access to external packages, or superior list management, I'd say stick with Pascal. If you ever need Python help, you still don't have to learn it, just ask and Python help will come to you. 😉 Raymond
  12. Hi @Jayme McColgan, You can also change your document units briefly to be in the units you need for the numerical drawing. Might save a bit of editing. To draw in inches, precede your drawing code with: UPI = vs.GetPrefReal(152) # save document scale vs.SetPrefReal(152, 1) # Inches And follow it with this: vs.SetPrefReal(152, UPI) # restore document scale If you set Pref152 to 25.4 you will be drawing in mm, and if you set it to 0.083333333, you will be drawing in feet, etc. HTH, Raymond
  13. @JBenghiat brings up a good point. You also have to test if a name conflict is with a Class Name or a name to another resource or object. The code I posted does not resolve that, and assumes the name in conflict is another Class Name. If you need help modifying the code, please write back, or have at it. You may modify the code above to your liking. Raymond
  14. Hello @Peter Z, If you want to use an existing name, you would need to go through the document and change all objects existing in the old class to the new (existing) class. This can be achieved with: ForEachObject() and ForEachObject(). Here is a quickly crafted script to change one class to another. USE WITH CAUTION AND ALWAYS USE ON A COPY FIRST. PROCEDURE ChangeClassNames; { Change the name of a class to a new name. If objects exist in the OLD class, then } { change the Class Name of all objects in the document, and in the symbol library, } { that have an existing class name of kOldClass to the new class name kNewClass. } { THIS SCRIPT IS VERY LIGHTLY TESTED! } { TRY ON A COPY OF YOUR FILE AND CHECK RESULTS CARFEFULLY BEFORE PROCEEDING! } { 30 OCT 2023 — RAYMOND MULLIN } CONST kOldClass = 'oldClassName'; kNewClass = 'newClassName'; CR = c_h_r(13); { *** remove "_" characters before use *** } VAR LCnt, SCnt :Longint; procedure ChangeClass(H :Handle); { Change the class name to class kNewClass. } Begin SetClass(H, kNewClass); LCnt := LCnt + 1; End; { ChangeClass } function ChangeClass1(H :Handle) :Boolean; { Change the class name of any object that has a class of kOldClass to class kNewClass. } Begin if (GetClass(H) = kOldClass) then begin SetClass(H, kNewClass); SCnt := SCnt + 1; end; { if } End; { ChangeClass1 } BEGIN LCnt := 0; { count of changed objects on layers } SCnt := 0; { count of changed objects in symbols } if (GetObject(kNewClass) = nil) then { if New Class Name does not exist } RenameClass(kOldClass, kNewClass) else begin { if New Class Name exists } ForEachObject(ChangeClass, (C=kOldClass)); { change class name of all objects placed in document } ForEachObjectInList(ChangeClass1, 0, 2, FSymDef); { change class name of all objects in SymDef list } AlrtDialog(concat('# of objects on layers changed: ', LCnt, CR, '# of objects in symbols changed: ', SCnt, CR, 'Total objects changed: ', LCnt + SCnt)); end; { if / else } {DelClass(kOldClass);} { delete Old Class Name when done – OPTIONAL } SysBeep; { make noise when done } END; Run(ChangeClassNames); HTH, Raymond
  15. Hello @Peter Z, Yes, you can use RenameClass(oldname, newname). The real work in your question is the interface. Probably the simplest way would be to create a text file with a list of old and new names then write a script to read and process it. Not sexy but not too hard to code. A fancy dialog based UI will be 99% dialog programming, and 1% code execution. Unless this is a chore that you expect to repeat a lot, KISS. Raymond
  16. You can use the ForEachObject family of calls. There are four – ForEachObject(), ForEachObjectAtPoint(), ForEachObjectInLayer(), and ForEachObjectInList(). ForEachObject() takes criteria statements. The others work across Layers, with Lists, or at a Point. They take a little time to get proficient with them, but they are very powerful. If you search the forum for these commands you should find quite a few examples. Raymond
  17. Thanks, @michaelk, I was looking for that earlier and couldn't find it. I would definitely start there first. Much easier than making a PIO event-enabled, but I'd still like to know how kObjXPropTextStyleSupport affects things. Raymond
  18. @Sam Jones, Not sure if this is pertinent, but there is an Object Property for event-enabled PIO's that looks like it might be applicable. I don't have a way to test it now. If @JBenghiat chimes in you may get better advice. const ObjectPropID kObjXPropTextStyleSupport = 42; // NO // Controls whether parametric objects can use class text style attribute and get Text Style on OIP // // Boolean // // Set TRUE if the object supports this // // // e.g. Almost all text-related PIOs set this yes, for support by default. If I guess right, you would put it in event kObjOnInitXProperties {5} along with your other property settings with something like this: case theEvent of ... kObjOnInitXProperties: begin { 5 } result := SetObjPropVS(kObjXPropTextStyleSupport, TRUE); { 42, Controls whether parametric objects can use class text style attribute and get Text Style on OIP. } ... end; { 5 } Please post back if you get it to work, or not. I, for one, would really like to know. Good luck, Raymond
  19. Hi @stevenmorgan94, @Juliensv's method is a sound way to go, but as in all things Vectorscript, there are multiple ways to get to the same place. As luck would have it, I was playing with AddResourceToList() this past weekend, so here are two more ways to get to where you want. The first subroutine, GetSymsInFldr1, uses a WHILE loop to step through the contents of your Symbol Folder. The second subroutine, GetSymsInFldr2, uses ForEachObjectInList() to do the same thing. They are identical in function and nearly identical in size. Use the one that's easiest for you to follow, or try your hand at Julian's method. To run this example, change the value of the constant kSymFldrName to match a Symbol Folder name in your file. PROCEDURE xxx; { Two example subroutines showing how to build a Resource List of Symbol Names in user specified SymFolder. } { 24 Oct 2023 - Raymond J Mullin } CONST kSymFldrName = 'Your Symbol Folder Name'; VAR List16, ListSize :Longint; Function GetSymsInFldr1(FldrNam :String; var NumItems :Longint) :Longint; { Return a Resource List of all SymDefs in symbol folder FldrNam, and return the list size in NumItems. } Const kSymDefType = 16; Var H :Handle; ListID, I :Longint; Begin ListID := BuildResourceListN(kSymDefType, '', NumItems); { empty list of Symbol Defs } H := FInFolder(GetObject(FldrNam)); { first obj in Sym Folder } while (H<>nil) do begin if (GetTypeN(H) = kSymDefType) then I := AddResourceToList(ListID, H); H := NextObj(H); end; { while } NumItems := ResourceListSize(ListID); GetSymsInFldr1 := ListID; End; { GetSymsInFldr1 } Function GetSymsInFldr2(FldrNam :String; var NumItems :Longint) :Longint; { Return a Resource List of all SymDefs in symbol folder FldrNam, and return the list size in NumItems. } Const kSymDefType = 16; Var ListID, I :Longint; Function AddSym2List(H :Handle) :Boolean; { Return a Resource List of all SymDefs in symbol folder FldrNam. } Begin if (GetTypeN(H) = kSymDefType) then I := AddResourceToList(ListID, H); End; { AddSym2List } Begin { GetSymsInFldr2 } ListID := BuildResourceListN(kSymDefType, '', NumItems); { empty list of Symbol Defs } ForEachObjectInList(AddSym2List, 0, 0, FInFolder(GetObject(FldrNam))); { All objects, Shallow } NumItems := ResourceListSize(ListID); GetSymsInFldr2 := ListID; End; { GetSymsInFldr2 } BEGIN { Call first subroutine example and show the results. } List16 := GetSymsInFldr1(kSymFldrName, ListSize); AlrtDialog(concat('List#: ', List16, ' — List Size: ', ListSize)); { Call second subroutine example and show the results. } List16 := GetSymsInFldr2(kSymFldrName, ListSize); AlrtDialog(concat('List#: ', List16, ' — List Size: ', ListSize)); END; Run(xxx); HTH, Raymond
  20. Is it possible the outer PIO (Device) is overwriting the inner PIO (Socket) after the "Socket"."n_circuits" field is written to? If so, I have not been able to see where the previous data is stored. If I place a "Socket" PIO on the Design Layer and run the python script, the value for "n_circuits" is updated to 98. Only when it is embedded in the Device PIO does it not stay updated after the script finishes. Raymond
  21. I launched VW 2009 on an older Mac and confirmed SetAngle() does work, but only on Rectangles and Ovals as far as I could discern. It does not work on Arcs, Lines, Images, Symbols, or PIOs. I then restarted VW 2024, and got the same results. Conclusion: The function SetAngle() is not broken, it is just severely limited in what it will operate upon. For most needs, use HAngle() instead. Raymond
  22. Hi @Marissa Farrell, The Function Reference, HTML and online versions, call for a REAL number input. I haven't tried a VW version earlier than 2015 yet to see if it ever worked, but I'm about to fire up an old computer in a minute to see. More soon. Regardless if it ever worked, it doesn't seem to work now. All the best, Raymond
  23. Hello @Andreas, I tried to use vs.SetAngle() on Lines, Arcs, and Rects to no avail. I tried in VW 2024 and VW 2015 with the same result. I also tried in Python and Pascal, still nothing. It appears the command is not functioning as advertised. There are other ways to set the angle of objects. Here's a short Pascal script that shows the current angle of a Symbol or PIO (which includes the Data Tag), and changes it to the user's value. Here's a short script to show how to set an angle without using vs.SetAngle() import vs # Example script to change the angle of a Symbol or PIO. Ang0 = vs.GetSymRot(vs.FSActLayer()) Ang = vs.RealDialog("Angle: ", vs.Concat(Ang0)) InsPt = vs.GetSymLoc(vs.FSActLayer()) vs.HRotate(vs.FSActLayer(), InsPt, Ang-Ang0) vs.SysBeep() Raymond
×
×
  • Create New...