Jump to content

twk

Member
  • Posts

    877
  • Joined

  • Last visited

Everything posted by twk

  1. twk

    Vectors?

    Greetings Pythonistas How do you guys go about with Vector types in python? I understand VS had a native Vector type in python and multiplying/dividing? or adding/subtracting could be done directly in VS without external functions. Am I right to assume that this is not the case for python? That adding/multiplying/etc two vectors would require a custom/external function? eg v1 = (1, 4) v2 = (4, 9) #v1 * v2 would not work #you'd need a custom function? def vector_multiply(vec1, vec2): DP = (vec1[0]*vec2[0], vec1[1]*vec2[1]) return DP
  2. Thanks Hippocode and Dieter for replying. It would be easier to use a popup, which is what I've been using until I found out about the SymbolDisplayControl function. The reason I'm trying to get SymbolDisplayControl to work is because it has a bigger preview window. This exercise is to enable our users to browse our Architectural Details from an external file/files. By text search and visual display.
  3. There are a number of ways to tackle this. Below is one way of the many ways. Have a look at the vectorscript language guide to get a hang of the syntax required to know. Vectorscript is based off of the Pascal language. I have jumped from VS to python, so my syntax may be incorrect. Double check if it works on an empty file, just in case crashes etc. occur. That is my disclaimer by the way. hehe I am by no means an expert, just an eager learner like yourself no doubt. PROCEDURE LineWeightChange; { (c) twk based off of original code by Petri Sakkinen 2008 } CONST newWeight = 20; PROCEDURE ChangeIt (h : HANDLE); VAR oldLW : INTEGER; BEGIN oldLW := GetLW(h); IF (oldLW = 2) OR (oldLW = 5) OR (oldLW = 10) OR (oldLW = 20) THEN SetLW(h, newWeight); END; BEGIN FOREACHOBJECT(ChangeIt, ((SEL=TRUE))); END; RUN(LineWeightChange);
  4. Ah ok. What does deleting resource list actually do? Does it delete the actual object(eg symbol) from the file? Including all classes/textures associated with objects in that symbol as well? Curious as to what Resource Lists actually are? Could you do the same with Python lists? Or are they totally different?
  5. Am wanting to use the symbol display call in a dialog. def vs.CreateSymbolDisplayControl(dialogID, itemID, symbolName, height, width, margin, renderMode, view): return None But it appears I cant browse/create a list(using BuildList) of symbols from an external file to be used in this function. So what I've done was, imported all the symbols into the file, so I can see them in the dialog through the SymbolDisplayControl, and once I've exited the dialog, purge all the symbols/classes/etc imported that are not in use. The idea is to browse a files symbol resources, and have a search text box to search through the file, while showing the symbol in dialog. Bascically what I'm wanting is: - Load Ext File - Be able to search the symbol list of that file - Display this symbol in the SymbolDisplayControl - If its selected in the ListBox, import this symbol. After importing that symbol, Im needing to delete every symbol thats not selected. Seeing that I imported everything, I need a way to filter out everything except the symbol selected. Will PM code if anyone wants to take a stab at it.
  6. PROCEDURE LineWeightChange; { (c) Petri Sakkinen 2008 } CONST { substitute these with the required values } oldWeight = 2; newWeight = 20; PROCEDURE ChangeIt (h : HANDLE); BEGIN SETLW(h, newWeight); END; BEGIN FOREACHOBJECT(ChangeIt, ((LW=oldWeight)&(SEL=TRUE))); END; RUN(LineWeightChange); the ForEachObject Call has two arguments - Callback function, A block of code to be run on the objects found via the criteria - Criteria, The criteria used to find objects you're wanting the callback function to be run on More Info : http://developer.vectorworks.net/index.php/VS:ForEachObject What Petri's code is doing is looking for all objects that have a line weight size specified by the oldWeight variable. ie oldWeight = 2; (LW=oldWeight) I added the SEL=True to the criteria to find only the objects that are selected. More Info on Criterias can be found here: http://developer.vectorworks.net/index.php/VS:Search_Criteria hth Tui
  7. Hi Hippocode, Do you mean using the ForEachObjectInList() ? How would you check/traverse a file to check for classes not in use? or textures?
  8. Is there any way/function via scripting to tell vectorworks to delete a resource eg class, if its not being used? Sort of like the purge command. But through scripting. Had a look at the DeleteResource but it doesnt tell you anything about how to deal with resources that are in use. Any thoughts VS/SDK experts? Cheers Tui
  9. My Bad, the description in the Wiki says : Which looks like it is the window of the worksheet when opened. Not sure why you'd ever need to know that. However in your script above, you can get the width of the placed worksheet by using HWidth. widthPlacedWS := HWidth(hW1) then use this to move your placed worksheet using HMove HMove(hW1, widthPlacedWS, 0) hth Tui
  10. Haven't tried this, but maybe have a look at http://developer.vectorworks.net/index.php/VS:GetWSPlacement PROCEDURE GetWSPlacement( worksheet :HANDLE; VAR top :INTEGER; VAR left :INTEGER; VAR bottom :INTEGER; VAR right :INTEGER); worksheet HANDLE Handle to worksheet. top INTEGER X-coordinate of top left corner of worksheet window. left INTEGER Y-coordinate of top left corner of worksheet window. bottom INTEGER X-coordinate of bottom right corner of worksheet window. right INTEGER Y-coordinate of bottom right corner of worksheet window. Calculate width from those variables. Then HMove(handle_to_worksheet, width, 0) ? or After it's placed you could maybe use HWidth(handle_to_worksheet) to get width Cheers Tui
  11. Hi JMiller I use Aptana Studio 3. 1. Set your project directory in Aptana 2. Add this location(in step 1) to the Environment Paths in vectorworks. (Under Scripts > Script Options) [You will have to search your workspace, because ours is totally different from the one thats shipped with VW] 3. Have a look at this post, for further info on Pythons equivalent of include methods and python caching etc. https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=220857#Post220857
  12. Interesting to find out what version of Vectorworks you're using. I know VW2016 added a couple of more criteria/functions to the worksheets. Also you could attach the file here to let others try and duplicate the issue and give help hth Tui
  13. Thank you Markus!. I had a script for toggling certain class visibilities a while back. The toggling worked in 2D using the ShowClass/HideClass/GrayClass calls, but could never work in 3D openGL view. Adding the LayerOption reset call you mentioned fixed this. Much appreciated. Tui
  14. I believe the fillobj Function has to be a procedure that accepts a single handle argument. PROCEDURE fillObj(h:HANDLE); BEGIN SetFPat(h, 1); SetFillBack(h, 1236); END;
  15. +1 Would love to see the end of "sheets" as well. I guess building control authorities will need to translate to this method too though. Interesting point by Benson: Thinking of the Microsoft Hololens tech, this would be crazy cool.
  16. Ha! Archeology and Cryptology, now thats what you call a skill-set! What's interesting orso, is that the VW Dev Wiki [http://developer.vectorworks.net/] is littered with references to the Vectorlabs website, which I thought would be managed by Nemetschek, but now sounds like it isn't the case and is run by users? Anyhow, that is great news that it will be back soon. Very grateful, Tui
  17. Oh ok cool, thanks Dieter. Do you know what this part of the example code does? : if paramHandle == 0: paramName = 'PythonSample_ObjectPt3' Is that checking to see if there is no handle to the PIO object to force a PIO name? What is the benefit of doing this? Thanks Tui
  18. Any updates guys, this was such an invaluable resource.. no where else can you find info on the Color changes from VW2008 and the ever cryptic List Browser! It was so well documented. Hope it comes back soon! Below are a couple of webclippings for anyone needing these, I clipped to my evernote for future reference, I'm now wishing I clipped the whole of vectorlab! If anyone has any please share, I'm looking for notes on the ListBrowser section. Index pitfalls - Vectorlab Absolute Origin - Vectorlab Thanks in advance Tui
  19. Greetings All, Just read through the code for the sample python PIO's on the DevWiki, just noticed that most function calls were passing variables into it after initialising it first to '0' or an empty string. global paramName, paramHandle, paramRecHandle, wallHandle ok, paramName, paramHandle, paramRecHandle, wallHandle = vs.GetCustomObjectInfo( paramName, paramHandle, paramRecHandle, wallHandle ) From 'PythonSample_ObjectPt3'. Why are variables being passed into the vs.GetCustomObjectInfo function? Shouldn't it be written like this: global paramName, paramHandle, paramRecHandle, wallHandle ok, paramName, paramHandle, paramRecHandle, wallHandle = vs.GetCustomObjectInfo() ?? Is the first method the correct one? Thanks Tui
  20. Thanks for the replies. I never knew the VW stored dimensions in worldCoordinates as 'mm' Just tested the Str2Num() and it didn't work. However the vs.ValidNumStr() call did. unitStr = '50mm' #unitNum = vs.Str2Num(unitStr) chk, unitNum = vs.ValidNumStr(unitStr) vs.Message(str(unitNum)) vs.MoveTo(0,0) vs.LineTo(unitNum, 0) the unitNum value draws a 50mm string regardless of document units. ..Interesting.. thanks again, Dieter and Hippothamus; Tui
  21. I think you can do what you want already through the Organization Palette. In our Aus/NZ Standard workspace, it's under "Tools > Organization.." Then under the "Viewports" Tab you see a list of all your viewports. Changing the view to "Visibilties" (You have two options : "Details" or "Visibilities"), and you'll see three columns "Viewports" > "Classes" > "Layers". The only pre-requisite is that to properly know what viewport is what, you need to name your viewports properly. (see attached image) Hope that helps Tui
  22. Thanks for the response Dieter. I guess it would be good to add them to the dlibrary. Unfortunatley, I am very new to coding, having just taught myself python over the last couple of months through the plethora of free online tutorials. Coming from a vectorscript background many concepts of object orientated programming have been hard to grasp. Like classes and abstract classes!? In saying that I really appreciate your library you've shared and I have been skimming over your code there trying to figure out what each call does etc, and going over my own notes. And I'm slowly learning. I only mention this because I know you've been mentioning to me to look at your library (in my last couple of posts) Appreciate your help. In between learning python I have tried to get into git/version control and that too is a bit over my head.. [pull requests?!commits!?] I guess in time I'll wrap my head around it. Thanks again Tui
  23. Anyone else notice issues with using the vs.IsPolyClosed or vs.GetVertexVisibility Functions? Here's what's happening: Where Last Segment is Hidden Case of Polygon If the [poly is a polygon] and [last vertex/segment is hidden] then the vs.IsPolyClosed call returns [False] -BUT- the vs.GetVertexVisibility call returns the last vertex/segment as visible(True). When really it should be reporting as hidden? Case of Polyline If the [poly is a polyline] and [last vertex/segment is hidden] then the vs.IsPolyClosed call returns [False]. -AND- the vs.GetVertexVisibility call returns the last vertex/segment as hidden(False). Which is CORRECT. Where Last Segment is Visible, but any other segment is Hidden BOTH SITUATIONS OF POLYLINE OR POLYGON Whatever segment/vertex is hidden is reporting as hidden using vs.GetVertextVisibility, but the vs.IsPolyClosed is reporting as True, when really it should be False? Here's my script below that tests these functions on either polyline or polygon, advice on corrections are welcome: h = vs.FSActLayer() PolyTypes = [5, 21] cntr = vs.HCenter(h) if vs.GetTypeN(h) in PolyTypes: chkClosed = vs.IsPolyClosed(h) cntrStr = 'Is Closed :' + str(chkClosed) vs.MoveTo(cntr) vs.CreateText(cntrStr) NVerts = vs.GetVertNum(h) #vs.Message(str(NVerts)) for vrtx in range(1, NVerts+1): check = vs.GetVertexVisibility(h, vrtx-1) pts = vs.GetPolyPt(h, vrtx) vs.MoveTo(pts) dispStr = 'vertextNum : '+str(vrtx) + ', '+ vs.Chr(13) + 'Visible : '+str(check) vs.CreateText(dispStr) #vs.Locus(pts) vs.SetDSelect(h) Script basically: 1. Checks whether Selected obj is a Poly 2. Places text objects with info vertex number, and visibility 3. Plus text on the center of the Poly saying whether it's closed or not {Using VW2015 SP4} Thanks Tui
×
×
  • Create New...