Jump to content

Sloader

Member
  • Posts

    39
  • Joined

  • Last visited

Everything posted by Sloader

  1. I am scripting this because I will be repeating it frequently. I have a set of loci that I need to replace with symbols, a different symbol depending on a record value. My plan, which is a bit rough, was to have a loop for each of the 5 symbols which selects by the attribute 'canopyPNTSRec'.'RAND_COLOU' and then replaces with the appropriate symbol. I have two problems: The only procedure I can find to replace sybols "vs.SetHDef" doesn't apparently work on loci The criteria for selection (('canopyPNTSRec'.'RAND_COLOU'=1)) needs to be re-formated for python but I can't get my head around how newsym1 = 'Canopy-1' def ReplaceRAND1s(h): vs.SetHDef(h, newsym1) vs.ForEachObject(ReplaceRAND1s,("INSYMBOL & INVIEWPORT & ('canopyPNTSRec'.'RAND_COLOU'=1)") )
  2. Cheers Pat! GetLocus3D is much better for what I want, I use the wiki to search for functions but it's easy to miss useful ones. As far as I can tell (and I may be wrong) with Python GetLocus3D returns a tuple rather than individual parameters so I have to extract Z value. I could have used your Vectorscript but learning some Python is hopefully a by product of automating some things in vectorworks. The code below seems to work vs.DSelectAll() MyZ = -100 def Execute(h): TupXYZ = vs.GetLocus3D(h) pZ = TupXYZ[2] if pZ < MyZ: vs.SetSelect(h) vs.ForEachObject(Execute,"T=LOCUS3D") vs.DeleteObjs()
  3. I am importing XYZ survey data and null data points are set to -9999. I need to delete these null data points (Loci with a Z value of -9999) I have managed to get this working for small areas of data using ForEachObject and checking the ZCoordinate but it's too slow for big sections. Any other approaches that might be quicker? nulv = int("-900") def deletenulls(h): HeightValue = vs.ZCoordinate("T=LOCUS3D") if HeightValue < nulv: vs.DelObject(h) vs.ForEachObject(deletenulls,"T=LOCUS3D")
  4. Thanks for trying, I can't see how I would ever have found vs.GetVPGroup would get a handle to the cameras - shame the view doesn't update. I have been trying to use vs.SetViewMatrix with the cameras deleted which does update and I can make incremental changes to the views but I haven't figured out how to make a simple 20degree rotation. I did the rotations manually then checked the parameters and it seems it isn't just the Y Rotation angle that changes. The sequence of parameters below are for a set of cameras rotated 20 degrees - I can't figure out why the offsets (X,Y,Z) change RotX=-90.0RotY=90.0RotZ=0.0X=415369.5 Y=94456.215 Z=105.2183062590922 RotX=90.0RotY=70.0RotZ=180.0X=415341.2491173034 Y=94456.215 Z=66.99958883375739 RotX=90.0RotY=50.00000000000002RotZ=180.0X=415301.6304000912 Y=94456.215 Z=40.748113042233484 RotX=90.0RotY=30.000000000000018RotZ=180.0X=415255.4224503691 Y=94456.215 Z=29.630194295498455
  5. I I would like to duplicate a viewport (linked to a camera) and change the rotation of the camera in the new viewport From the reference I have found VS:GetViewMatrix and VS:SetViewMatrix and managed to get, change and set the rotationXAng parameter but it doesn't change the direction of the camera. Hoffset = 0.117236 Y =0 viewport = vs.FSActLayer() VPparams = vs.GetViewMatrix(viewport) VPparamsList = list (VPparams) Myoffset = VPparamsList[1] MyrotationXAng = VPparamsList[2] MyrotationYAng = VPparamsList[3] MyrotationZAng = VPparamsList[4] MyrotationYAng = 45 VpCylR1 = vs.HDuplicate(viewport,Hoffset,Y) vs.SetViewMatrix(VpCylR1, Myoffset, MyrotationXAng, MyrotationYAng, MyrotationZAng) VpCylR2 =vs.HDuplicate(viewport,Hoffset*2,Y) VpCylR3 =vs.HDuplicate(viewport,Hoffset*3,Y) VpCylL1 =vs.HDuplicate(viewport,0-Hoffset,Y) VpCylL2 =vs.HDuplicate(viewport,0-Hoffset*2,Y) VpCylL2 =vs.HDuplicate(viewport,0-Hoffset*3,Y)
  6. Is this what you are looking for? https://developer.vectorworks.net/index.php/VS:SetObjMaterialHandle FUNCTION SetObjMaterialHandle( VAR objectHandle :HANDLE; materialHandle :HANDLE) : BOOLEAN;
  7. I tried to translate your code and I think I got it to run but it crashed, I think it was stuck in a loop looking for the previous object or something. vs.ForEachObjectInLayer seems much better than While MyObject <> Nil DO for me. Defining the new procedure and passing handles around makes a lot more sense now.
  8. The code below uses "ForEachObjectInLayer" and seems to work. I am a bit fuzzy on how to correctly pass the HANDLE from ForEachObject to SetParent isBatch = True MyLayer = vs.GetLayerByName('LiDARContours') def sendtoconstraints(h): vs.SetParent(h, MyLayer) Contours1m = vs.ImportDXFDWGFile('/LiDARScript/1m3dContours.dxf', isBatch) vs.ForEachObjectInLayer(sendtoconstraints, 0, 0, 0 ) Contours50cm = vs.ImportDXFDWGFile('/LiDARScript/50cm3dContours.dxf', isBatch) vs.ForEachObjectInLayer(sendtoconstraints, 0, 0, 0 ) MyLayer = vs.GetLayerByName('Noise') RoadLQ16 = vs.ImportDXFDWGFile('/LiDARScript/RoadLQ16.dxf', isBatch); vs.ForEachObjectInLayer(sendtoconstraints, 0, 0, 0 ) RailLQ16 = vs.ImportDXFDWGFile('/LiDARScript/RailLQ16.dxf', isBatch); vs.ForEachObjectInLayer(sendtoconstraints, 0, 0, 0 )
  9. I think the issue is that the vs.ImportDXFDWGFile function returns and integer not the objects imported? therefore the HANDLE isn't any use? I have found the code below but I can't make much sense of it # use : assigns a new layer to objects selected by criteria def object_layer_assign_criteria(vSelection_Criteria, vLayer_Destination_Name): vLayer_Destination_Handle = vs.GetLayerByName(vLayer_Destination_Name) if vLayer_Destination_Handle == None: vLayer_Actual_Handle = vs.ActLayer() vLayer_Actual_Name = vs.GetLName(vLayer_Actual_Handle) vs.Layer(vLayer_Destination_Name) vLayer_Destination_Handle = vs.ActLayer() vs.Layer(vLayer_Actual_Name) def object_layer_assign_iterator(vObject_Handle): vs.SetParent(vObject_Handle, vLayer_Destination_Handle) vs.ForEachObject(object_layer_assign_iterator, vSelection_Criteria)
  10. I am trying to automate importing a number of DXF files, I got this working in batch mode based on help here. isBatch = True RoadLQ16 = vs.ImportDXFDWGFile('/Users/some.guy/Desktop/Script/RoadLQ16.dxf', isBatch) This works fine but I want to group the imports into specific layers. I have tried using vs.SetParent and VS:CreateDuplicateObject but I am misunderstanding something about handles (I think) These attempts don't work isBatch = True RoadLQ16 = vs.ImportDXFDWGFile('/Users/some.guy/Desktop/Script/RoadLQ16.dxf', isBatch) vLayer_Destination_Handle = vs.GetLayerByName('Noise') vs.CreateDuplicateObject('RoadLQ16', vLayer_Destination_Handle) isBatch = True RoadLQ16 = vs.ImportDXFDWGFile('/Users/some.guy/Desktop/Script/RoadLQ16.dxf', isBatch) vLayer_Destination_Handle = vs.GetLayerByName('Noise') vs.SetParent('RoadLQ16', vLayer_Destination_Handle)
  11. Thanks for clarifying, maybe I need to look at the SDK. Not sure I really see the point in the function if all it does is launch the dialogue, that makes the process slower than dragging a dxf onto the page.
  12. I am trying create a script that automates the importing of a variety of files created by a QGIS script (DXF, SHP and some images). As I am new to scripting in VW (and not very good in general) I am trying to get started by importing a single DXF file. I have tried using vs.ImportSingleDXFDWG(pathtomyfile) but that just launches the import dialogue. The APi reference doesn't provide many clues as to the arguments etc for the function or how it works so I don't really know where to start without going to square one and start learning python properly. I am using a mac so I think there might be issues the the path format
  13. That works for specific vertices, so I guess I need to loop through them all some how.
  14. I would like to perform some polyline smoothing in a marionette, is there a node that will work? Ideally radius smoothing
×
×
  • Create New...