Message 1 of 12

Not applicable
02-11-2017
10:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
HI, I am using vb.net for writing a new dll for Revit 2017.
I have found a C# sample "Get CenterLinesCurves from rebar" and I have converted it to VB:NET, but I have a problem with all RebarShape.GetCurvesForBrowser().
the function is red underlined and I receive this message: reference to a non-shared member requires an object reference.
What am I doing wrong?
Thanks
Stefano
Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports Autodesk.Revit.DB Imports Autodesk.Revit.DB.Structure Imports Autodesk.Revit.UI Imports Autodesk.Revit.UI.Selection Imports Autodesk.Revit.Attributes Imports System Imports Autodesk.Revit.ApplicationServices Namespace CreateImageRebar <TransactionAttribute(TransactionMode.Manual)> <RegenerationAttribute(RegenerationOption.Manual)> Public Class ReinforcementDetail Implements IExternalCommand 'Clase de filtro de selección Public Class RebarPickFilter Implements ISelectionFilter Public Function AllowElement(e As Element) As Boolean Implements ISelectionFilter.AllowElement Return (e.Category.Id.IntegerValue.Equals(CInt(BuiltInCategory.OST_Rebar))) End Function Public Function AllowReference(r As Reference, p As XYZ) As Boolean Implements ISelectionFilter.AllowReference Return False End Function End Class Public Function Execute(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Autodesk.Revit.UI.Result Implements IExternalCommand.Execute 'Public Function Execute(commandData As ExternalCommandData, ByRef message As String, elements As ElementSet) As Result Dim uiApp As UIApplication = commandData.Application Dim doc As Document = uiApp.ActiveUIDocument.Document Dim pickedRef As Reference = Nothing Dim sel As Selection = uiApp.ActiveUIDocument.Selection Dim selFilter As New RebarPickFilter() pickedRef = sel.PickObject(ObjectType.Element, selFilter, "Seleccione una Armadura") 'Obtener referencia Dim el As Element = doc.GetElement(pickedRef) Dim myRebar As Rebar = TryCast(el, Rebar) Dim lc As List(Of Curve) = myRebar.GetCenterlineCurves(True, True, False).ToList() Dim curvesForBrowser As IList(Of Curve) = RebarShape.GetCurvesForBrowser() Dim hookangle0 As Integer = RebarShape.GetDefaultHookAngle(0) Dim orient0 As RebarHookOrientation = RebarShape.GetDefaultHookOrientation(0) Dim hookangle1 As Integer = RebarShape.GetDefaultHookAngle(1) Dim orient1 As RebarHookOrientation = RebarShape.GetDefaultHookOrientation(1) Dim labelParamIdToDimId As IDictionary(Of ElementId, ElementId) = New Dictionary(Of ElementId, ElementId)() For Each [dim] As Dimension In familyDimensions Try Dim famParam As FamilyParameter = [dim].FamilyLabel If famParam Is Nothing Then Continue For Try End If labelParamIdToDimId(famParam.Id) = [dim].Id Catch generatedExceptionName As Autodesk.Revit.Exceptions.InvalidOperationException Continue For Try End Try Next ' Get the shape definition : constraints should ' be available for every definition. ' Get all the shape segments (indexes of segments) ' and their corresponding constraint parameter ids ' The RebarShapeSegment should be in the same order ' as the curvesForBrowser. ' The constraint param ids should correspond to ' the dimension label param ids. Dim defBySeg As RebarShapeDefinitionBySegments = TryCast(RebarShape.GetRebarShapeDefinition(), RebarShapeDefinitionBySegments) Dim segmentPosToLabel As IDictionary(Of Integer, String) = New Dictionary(Of Integer, String)() For ii As Integer = 0 To defBySeg.NumberOfSegments - 1 Dim seg As RebarShapeSegment = defBySeg.GetSegment(ii) Dim constraints As IList(Of RebarShapeConstraint) = seg.GetConstraints() For Each constraint As RebarShapeConstraint In constraints Dim paramID As ElementId = constraint.GetParamId() If (paramID = ElementId.InvalidElementId) OrElse Not labelParamIdToDimId.ContainsKey(paramID) Then Continue For End If Dim labelName As String = "" For Each param As Parameter In RebarShape.Parameters If param.Id = paramID Then labelName = param.Definition.Name Exit For End If Next segmentPosToLabel.Add(ii, labelName) Next Next Dim curvesForPicture As IList(Of Curve) = New List(Of Curve)() For ii As Integer = 0 To defBySeg.NumberOfSegments - 1 Dim curve As Curve = curvesForBrowser(ii) Dim label As String = "" If Not segmentPosToLabel.TryGetValue(ii, label) Then Continue For End If Next Return Result.Succeeded End Function End Class End Namespace
Solved! Go to Solution.