Jump to content

Sloader

Member
  • Posts

    28
  • Joined

  • Last visited

Reputation

5 Neutral

Personal Information

  • Location
    United Kingdom

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. @DomC The "Try Except" approach works nicely so I have managed to get VW to do what I want and learnt something new in Python. I am still using the "Pitched" attribute from GIS so I can prevent buildings above or below a certain size from having pitched roofs but I should now be able to relax the restriction on how complex a roof I let it try and make pitched. try: vs.SetRField(h2,'Massing Model','DrawPitchedRoof',Pitched) except: pass
  2. The try / except approach looks ideal - When I get time I'll try setting the roof to pitched (True) and false if it fails The something heavy on the key option was explored E7 S7 of the Simpsons which clearly demonstrates some of the drawbacks of this approach
  3. Script below is cleaned up a bit. It now works with heights from my records and I have got GIS to do some guessing about which lines are too complex for a pitched roof in addition to cleaning up angles near 0 or 90. There will still be many polylines that are too complex so it would be good to suppress the failure messages so I don't have to sit and hold the return key whilst it runs, this would also mean I can relax the inputs on which polylines it tries to add a pitched roof to. storeyht=3 vs.SelectObj("T=GROUP") vs.Ungroup() def gone(h1): vs.ConvertToPolygon(h1, 0) vs.ForEachObject(gone, "T=POLYLINE" ) #loop for all the polylines and convert them to polygons def extrudebuildings(h):#make massing model buidlings based on records RecName=vs.GetName(vs.GetRecord(h,1)) Pitched=vs.GetRField(h, RecName,'PITCHED')#Get pitched boolean from record AOD=vs.GetRField(h, RecName,'TM_mean')#Get AOD height from record TM=eval(vs.GetRField(h, RecName,'TM_mean'))#convert AOD height to number SM=eval(vs.GetRField(h, RecName,'SM_max'))#Get max surface height as number BHT=SM-TM Storeys = ((SM-TM)-2)/storeyht Floors = vs.Round(Storeys) vs.CreateCustomObjectPath('Massing Model', h, None) h2 = vs.LNewObj() # get handle to new massing model vs.SetRField(h2,'Massing Model','2Ddisplay','Roof') vs.SetRField(h2,'Massing Model','Height',BHT) vs.SetRField(h2,'Massing Model','NumFloors',Floors) vs.SetRField(h2,'Massing Model','WallMatl','') vs.SetRField(h2,'Massing Model','Custom Roof','False') vs.SetRField(h2,'Massing Model','Overhang','0.3') vs.SetRField(h2,'Massing Model','RoofThk','0.3') vs.SetRField(h2,'Massing Model','RoofMatl','') vs.SetRField(h2,'Massing Model','DrawPitchedRoof',Pitched) vs.SetRField(h2,'Massing Model','EaveStyle','Square') vs.SetRField(h2,'Massing Model','RoofPitch','35') vs.SetRField(h2,'Massing Model','DrawFloorLevels','True') vs.SetRField(h2,'Massing Model','FloorThk','0.3') vs.SetRField(h2,'Massing Model','Use Site Modifiers','False') vs.SetRField(h2,'Massing Model','Use Fence','True') vs.SetRField(h2,'Massing Model','Fence offset','0.02') vs.SetRField(h2,'Massing Model','Use Shadow','False') vs.Move3DObj(h2, 0, 0, AOD) vs.ForEachObject(extrudebuildings, "T=POLY" ) #loop for all the polygons
  4. I am trying to create a site model that has a hole in it. The single crop object does have a hole but the resulting donut is more of a cake. Can it be done without cutting a thin slice out of the donut?
  5. When creating massing models some don't work because of the line geometry, this is fine but can I let VW ignore the issues without me holding down the return key?
  6. I found my error but can't see how to delete this topic My eventual goal is to build a set of massing models based on polygons with records for height etc. I can't see anything in the help files for the massing model custom object so what I have so far is based on exporting a script from a file with massing models in it. It looks like I should be able to change the fields for number of floors and height etc based on the records once I have got it to build massing models. So far what I have runs and creates massing models but they don't show on screen or export, I can select them and see their properties but there is clearly something very wrong with them. vs.SelectObj("T=GROUP") vs.Ungroup() def gone(h1): vs.ConvertToPolygon(h1, 0) vs.ForEachObject(gone, "T=POLYLINE" ) #loop for all the polylines and convert them to polygons def extrudebuildings(h):#Extrude buidlings based on records vs.CreateCustomObjectPath('Massing Model', h, none) h2 = vs.LNewObj() # get handle to new symbol instance vs.Record(vs.LNewObj(),'Massing Model'); vs.SetRField(vs.LNewObj(),'Massing Model','2Ddisplay','Roof'); vs.SetRField(vs.LNewObj(),'Massing Model','Height','6.096'); vs.SetRField(vs.LNewObj(),'Massing Model','NumFloors','2'); vs.SetRField(vs.LNewObj(),'Massing Model','WallMatl',''); vs.SetRField(vs.LNewObj(),'Massing Model','Custom Roof','False'); vs.SetRField(vs.LNewObj(),'Massing Model','Overhang','0.3048'); vs.SetRField(vs.LNewObj(),'Massing Model','RoofThk','0.3048'); vs.SetRField(vs.LNewObj(),'Massing Model','RoofMatl',''); vs.SetRField(vs.LNewObj(),'Massing Model','DrawPitchedRoof','False'); vs.SetRField(vs.LNewObj(),'Massing Model','EaveStyle','Square'); vs.SetRField(vs.LNewObj(),'Massing Model','RoofPitch','35'); vs.SetRField(vs.LNewObj(),'Massing Model','DrawFloorLevels','True'); vs.SetRField(vs.LNewObj(),'Massing Model','FloorThk','0.3048'); vs.SetRField(vs.LNewObj(),'Massing Model','Use Site Modifiers','False'); vs.SetRField(vs.LNewObj(),'Massing Model','Use Fence','True'); vs.SetRField(vs.LNewObj(),'Massing Model','Fence offset','0.0254'); vs.SetRField(vs.LNewObj(),'Massing Model','Use Shadow','False'); vs.ForEachObject(extrudebuildings, "T=POLY" ) #loop for all the polygons
  7. Move3DObj does work, many thanks. I see its listed right by Move3D in the Function reference and I still didn't spot it. I also seem to be missing something about how to use the search tool in the procedures dialogue within VW.
  8. I have the script below which places, scales and rotates tree symbols based on a set of 2d Loci created in GIS. I would like to set the Z position of the symbols based on an attribute but can't get it to work. I am trying to use Move3D as below but no joy. def ReplaceRAND1s(h):#Function to replace all loci from imported shapefile with scaled canopy symbols rand=vs.GetRField(h, 'TreePointsForSymbolsRec','RAND_COLOU')#Get the random colour for the canopy loci sym= vs.Concat('Canopy-'+ rand)#Convert the colour code to canopy symbol name ScaleX=vs.GetRField(h, 'TreePointsForSymbolsRec','RAD')#Get scale from loci record ScaleY=vs.GetRField(h, 'TreePointsForSymbolsRec','RAD')#Get scale from loci record ScaleZ=vs.GetRField(h, 'TreePointsForSymbolsRec','rvalue_1')#Get tree height from loci record AOD=vs.GetRField(h, 'TreePointsForSymbolsRec','DTM_1')#Get AOD height from loci record X, Y = vs.GetLocPt(h)#Get location from loci to place symbol randrot= vs.Random()*100 #create a random number to rotate the symbol by vs.Symbol(sym, X, Y, randrot) # place symbol based on loci postion, random colour and random rotation vs.Move3D(0, 0, AOD) h2 = vs.LNewObj() # get handle to new symbol instance vs.SetObjectVariableInt(h2, 101, 3) #Set symbol scaling to asymetric vs.SetObjectVariableReal(h2, 102, ScaleX)#Set X scale vs.SetObjectVariableReal(h2, 103, ScaleY)#Set Y scale vs.SetObjectVariableReal(h2, 104, ScaleZ)#Set Z scale/ height vs.DelObject(h)#clean up loci vs.ForEachObject(ReplaceRAND1s, ("T=LOCUS")) #loop for all the loci in the file TreeLoci.vwx
  9. Yes, I import shapefiles frequently - the importer is flakey but does mean you have records to to use for things like scaling tree symbols or extruding buildings which you don't get with DWG/DXF. vs.ImportDXFDWGFile is a pain as you can't (as far as I know) set the options like units and prefixes from the script. I'll look at adding some feedback. Doing some digging it looks like I might be able to use vs.SetLastDXFImportOpt(selector, value) to sort out my DXF imports
  10. vs.LNewObj() is the Key - no idea how I would have found it, I see its filed under document list handling which now makes sense. Better than doing receptive tasks manually, but VW could be more accessible. I need to spend the time to figure out a proper environment with debugging etc but that looks painful. I can't see a way to import a shapefile which is a shame. Code below seems to work - Takes tree canopy points created by a GIS script from LiDAR def ReplaceRAND1s(h):#Function to replace all loci from imported shapefile with scaled canopy symbols rand=vs.GetRField(h, 'TreePointsForSymbolsRec','RAND_COLOU')#Get the random colour for the canopy loci sym= vs.Concat('Canopy-'+ rand)#Convert the colour code to canopy symbol name ScaleX=vs.GetRField(h, 'TreePointsForSymbolsRec','RAD')#Get scale from loci record ScaleY=vs.GetRField(h, 'TreePointsForSymbolsRec','RAD')#Get scale from loci record ScaleZ=vs.GetRField(h, 'TreePointsForSymbolsRec','rvalue_1')#Get height from loci record X, Y = vs.GetLocPt(h)#Get location from loci to place symbol randrot= vs.Random()*100 #create a random number to rotate the symbol by vs.Symbol(sym, X, Y, randrot) # place symbol based on loci postion, random colour and random rotation h2 = vs.LNewObj() # get handle to new symbol instance vs.SetObjectVariableInt(h2, 101, 3) #Set symbol scaling to asymetric vs.SetObjectVariableReal(h2, 102, ScaleX)#Set X scale vs.SetObjectVariableReal(h2, 103, ScaleY)#Set Y scale vs.SetObjectVariableReal(h2, 104, ScaleZ)#Set Z scale/ height vs.DelObject(h)#clean up loci vs.ForEachObject(ReplaceRAND1s, "T=LOCUS" ) #loop for all the loci in the file
  11. Gotcha! thanks The loop just deletes everything it created. This also explains why I was getting confusing results trying to attach a record to the new symbols. Now I am struggling with attaching the record to the new symbol and transferring data into the values def ReplaceLOCI(h): ScaleX=vs.GetRField(h, 'canopyPNTSRec','RAD') ScaleY=vs.GetRField(h, 'canopyPNTSRec','RAD') ScaleZ=vs.GetRField(h, 'canopyPNTSRec','rvalue_1') X, Y = vs.GetLocPt(h) CreatedSymbol=vs.Symbol('Canopy-1', X, Y, 0) SymbolHandle= vs.GetObject(CreatedSymbol) vs.SetRecord(SymbolHandle,'canopyPNTSRec') vs.SetRField(SymbolHandle, 'canopyPNTSRec','RAD', ScaleZ) vs.DelObject(h) vs.ForEachObject(ReplaceLOCI, "T=Locus" )
  12. The code supplied below doesn't work as if you have the vs.DelObject(h) line in it deletes the newly created symbols as well as the loci, which doesn't make sense to me. When the new symbol is inserted that object seems to take the reference of h. If I run a later line referencing h such as vs.SetRecord(h,'canopyPNTSRec') the function is applied to the new symbol which would be workable if I could set the field values based on my ScaleX, ScaleY and ScaleZ variables def ReplaceRAND1s(h): X, Y = vs.GetLocPt(h) vs.Symbol(newsym1, X, Y, 0) vs.DelObject(h)
  13. After hours of searching I did find SetObjectVariable and verified by looking in a python script exported by VW. The below assumes I have manually converted all loci to symbols so attaching records and transferring the values from loci to new symbols is the next bit to look at. Cheers again def ReplaceRAND1s(h): X, Y = vs.GetLocPt(h) rand=vs.GetRField(h, 'canopyPNTSRec','RAND_COLOU') sym= vs.Concat('Canopy-'+ rand) ScaleX=vs.GetRField(h, 'canopyPNTSRec','RAD') ScaleY=vs.GetRField(h, 'canopyPNTSRec','RAD') ScaleZ=vs.GetRField(h, 'canopyPNTSRec','rvalue_1') symh= vs.Symbol(sym, X, Y, 0) vs.SetObjectVariableInt(symh, 101, 3) vs.SetObjectVariableReal(symh, 102, ScaleX) vs.SetObjectVariableReal(symh, 103, ScaleY) vs.SetObjectVariableReal(symh, 104, ScaleZ) vs.ForEachObject(ReplaceRAND1s, "L='canopyPNTS'" )
  14. Thanks for the help I saw that placing a symbol at each of the loci would be easier but the next step is to scale the symbol based on a field value so I don't want to lose the records. The correct usage of vs.SetHDef(h, vs.GetObject(newsym1)) is useful to know as I could replace all loci with a symbol before I run the script. I have cleaned up the concept a little so I don't need 5 loops as I can pick the right symbol as part of the one function Currently struggling with the scaling as the below doesn't scale the symbol in place and I expect its to do with coordinates def ReplaceRAND1s(h): rand=vs.GetRField(h, 'canopyPNTSRec','RAND_COLOU') sym= vs.Concat('Canopy-'+ rand) vs.SetHDef(h, vs.GetObject(sym)) ptXY = vs.GetSymLoc(h) PtX = ptXY[0] PtY = ptXY[1] vs.HScale2D(h, PtY, PtX, 1, 1, 0) vs.ForEachObject(ReplaceRAND1s, "L='canopyPNTS'" )
  15. 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)") )
×
×
  • Create New...