algorithmic modeling for Rhino
I am trying to replace specific Point3D points in a list with "Null" values. How can I do this in VBScript with the System.DBNull class?
I tried this after a conditional statement:
ptlist.Item(i) = System.DBNull
The above is unsuccessful. Does anyone know the correct syntax?
Tags:
Try this :
Dim ptl As New list(Of Object)
For i As Integer = 0 To 9 Step 1
Dim np As New point3d(0, 2, i)
ptl.add(np)
NextDim nu As system.Nullable = Nothing
ptl(5) = nu
a = ptl
First thing to understand is that Point3D is a structure (or Value Type). Structures are never null as their data is stored locally rather than the variable being a pointer to some location in memory where the actual data resides.
There are however ways around this. One way is to 'box' the structure by creating a List(Of Object). System.Object is a Reference Type and therefore can be null, and it can also wrap around a Value Type such as Point3d. Boxing has always been possible in .NET but there's a sacrifice to be paid in terms of type-safety and performance.
.NET 4.0 introduced nullable modifiers which allows you add nullability to Value Types. This is a good topic about value vs. reference and boxing vs. nullable: http://visualbasic.about.com/od/usingvbnet/a/nullabletypes.htm
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David. This is very helpful!
On an unrelated note, I would like to suggest that "Text Tag" components get outputs so that they can be duplicated and relocated. This would be incredibly useful for laying out fabrication elements that reference a 3D model. (Also, there should be a component to decompose a tag into a point location and a string though there are scripts floating around that do this already.)
so if i understand this correctly you are creating an object, wrapping the structure in the object, and then nulling the object?
It's not the same, but in general, I would use the Point3d.Unset value, would this not be an easier solution for this case?
It could be. Though an unset point is not the same as a null. Grasshopper itself stores point data in GH_Point classes, which can both be null and can wrap around an unset point. There is a subtle difference between these.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by