algorithmic modeling for Rhino

HI everyone! I need move a brep's control points by gh like Point deform component, but this component does not support brep.

So I want write a component that brep control points deform.

Like this command in rhino

Could anyone give me some suggestion? I found all function in rhinocommon sdk and didn't find the solution.

Thank you in advance--

Views: 1184

Replies to This Discussion

I'm pretty sure brep point deform hasn't been exposed in the SDK (C++ or RhinoCommon). If the brep consist of rectangular faces, you can try and mesh it using the component which makes the simplest possible mesh (I forgot its name).

Or otherwise convert the brep to a set of polyline boundaries, deform those, then somehow patch it back together...

Not ideal solutions but I can't think if a better way.

OK,I guessed the result. I hope it can be exposed in the sdk soon.

Now, I will use userdicionary to store the brep's verterPoints to solve My Problem.

Thank you!

Hi,Dear David. I have coded a component about brep deform. But I came into two Problem I can't solve. hope you can give some tips. The  component code is below. Trouble you compile it by vs--

Public Class BrepDeform
Inherits GH_Component
Public Reslist As New List(Of String)
Public Sub New()
MyBase.New("BrepDeform", "Deform", _
"移动物件的控制点" & vbCrLf & "(Move the control Point to change a object)", "SEG", "Modify")

End Sub
Public Overrides ReadOnly Property ComponentGuid As System.Guid
Return New Guid("8226e0ea-ed6b-47c2-8a24-244f044152d8")
End Get
End Property
Protected Overrides ReadOnly Property Internal_Icon_24x24() As System.Drawing.Bitmap
Return My.Resources.SEG_BrepDeform
End Get
End Property
Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_Component.GH_InputParamManager)
' pManager.AddTextParameter("Guid", "Id", "将要被替换的犀牛物件" & vbCrLf & "(RhinoObjects that will be replaced)", GH_ParamAccess.item)
'Dim guidParam As New Param_Guid
pManager.AddParameter(New Param_Guid, "Guid", "Id", "将要被替换的犀牛物件" & vbCrLf & "(RhinoObjects that will be replaced)", GH_ParamAccess.item)
pManager.AddPointParameter("ControlPoint3d", "C", "控制点的位置" & vbCrLf & "(Control Point's location)", GH_ParamAccess.item)
pManager.AddPointParameter("NewPoint3d", "P", "新控制点的位置" & vbCrLf & "(New Control Point's location)", GH_ParamAccess.item)
pManager.AddNumberParameter("Tolerace", "T", "输入点与物件实际控制点对比的精度" & vbCrLf & "(Tolerace for the Control Point match)", GH_ParamAccess.item, 0.1)

pManager.AddBooleanParameter("BlMove", "M", "如果是True则进行移动" & vbCrLf & "(If true Perform the Move)", GH_ParamAccess.item, False)

End Sub
Protected Overrides Sub RegisterOutputParams(ByVal pManager As Kernel.GH_Component.GH_OutputParamManager)
pManager.AddTextParameter("Result", "RG", "结果列表" & vbCrLf & "(Result)", GH_ParamAccess.list)
End Sub
Public Overrides ReadOnly Property Exposure As GH_Exposure
Return GH_Exposure.primary
End Get
End Property

Protected Overrides Sub SolveInstance(ByVal DA As Kernel.IGH_DataAccess)
If Banner.astrict.showmessage Then Return
Dim Ids As Guid = Guid.Empty
'Dim Ids As String = String.Empty
Dim tpt As Point3d = Point3d.Unset, opt As Point3d = Point3d.Unset
Dim tolar As Double = 0.1
Dim blMove As Boolean = False
If Not DA.GetData(0, Ids) Then Return
If Not DA.GetData(1, opt) Then Return
If Not DA.GetData(2, tpt) Then Return
If Not DA.GetData(3, tolar) Then Return
If Not DA.GetData(4, blMove) Then Return
If Not blMove Then
GoTo line1
Reslist.Add(Now & "_未替换!(Replace failed!)")
' Grasshopper.Instances.ActiveCanvas.ModifiersEnabled = False
End If

' rt.AddRange(docobjlist.Select(Function(geoobj As RhinoObject) GH_Convert.ObjRefToGeometry(New ObjRef(geoobj.Id))))
'Private Checked(5) As Boolean, Namestr() As String = {"Point", "Curve", "Brep", "Mesh", "TextDot", "TextEntity"}


Dim rh As RhinoDoc = Rhino.RhinoDoc.ActiveDoc
Dim rhobj As RhinoObject = rh.Objects.Find(Ids)
' Dim rhobj As RhinoObject = rh.Objects.Find(New Guid(Ids))

Dim bobj As BrepObject = CType(rhobj, BrepObject)
RhinoApp.RunScript("Cancel", False)
RhinoApp.RunScript("Cancel", False)

RhinoApp.RunScript("_SolidPtOn", False)
Dim gobjs As GripObject() = bobj.GetGrips
' rh.Views.RedrawEnabled = False
For Each grpobj As GripObject In gobjs

If grpobj.CurrentLocation.DistanceTo(opt) < tolar Then
Dim CurrentPln As Plane = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane
Dim tropt As New Point3d(opt), trtpt As New Point3d(tpt)
tropt.Transform(Transform.PlaneToPlane(Plane.WorldXY, CurrentPln))
trtpt.Transform(Transform.PlaneToPlane(Plane.WorldXY, CurrentPln))

Dim movestr As String = "_move " + String.Format("{0},{1},{2} ", tropt.X, tropt.Y, tropt.Z) + String.Format("{0},{1},{2} _Cancel _Cancel", trtpt.X, trtpt.Y, trtpt.Z)
RhinoApp.RunScript(movestr, True)
End If


'RhinoApp.RunScript("Cancel", False)
'RhinoApp.RunScript("Cancel", False)
'' rh.Views.RedrawEnabled = True
Reslist.Add(Now & "_替换成功!(Replace Success!)")
Catch ex As Exception
Reslist.Add(Now & "_替换失败!(Replace failed!)" & vbCrLf & ex.Message)

End Try
' Grasshopper.Instances.ActiveCanvas.ModifiersEnabled = True

line1: DA.SetDataList(0, Reslist)
End Sub

'Private Sub Testt_PingDocument(sender As IGH_DocumentObject, e As GH_PingDocumentEventArgs) Handles Me.PingDocument
' Dim Mbool = Aggregate bcbool In Checked Into cb = Any(bcbool)

' If Not Mbool Then
' Checked(0) = True
' Message = Namestr(0)
' Order = 0
' End If
'End Sub

End Class

The picture below shows the two question.

Question One I must use data dam, or the component can't batch deal the brep. I don't know why, I have You can give me a solution to make it working  normal not using the data dam

Question Two  I can not uset the Button component, If I use it, the gh canvas will die with some mouse event--. I have see this problem before in this forum,but there is no solution and explain. I want to know why and How to solve it. 

I don't know if I have made my question clear,if not give a message. Thank you! Thank you all.

The gh test file and 3dm test file in the upload files.







  • Add Photos
  • View All

© 2020   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service