Point Deform that can move brep's control Points - Grasshopper2024-03-28T22:33:55Zhttps://www.grasshopper3d.com/forum/topics/point-deform-that-can-move-brep-s-control-points?commentId=2985220%3AComment%3A1305284&feed=yes&xn_auth=noHi,Dear David. I have coded a…tag:www.grasshopper3d.com,2015-06-08:2985220:Comment:13052842015-06-08T08:02:58.713Zhuaxiamengqinghttps://www.grasshopper3d.com/profile/huaxiamengqing
<p>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--</p>
<div style="color: #00ff00; background-color: #000000;"><p>Public Class BrepDeform<br></br> Inherits GH_Component<br></br> Public Reslist As New List(Of String)<br></br> Public Sub New()<br></br> MyBase.New("BrepDeform", "Deform", _<br></br> "移动物件的控制点" & vbCrLf & "(Move the control Point to change a object)",…</p>
</div>
<p>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--</p>
<div style="color: #00ff00; background-color: #000000;"><p>Public Class BrepDeform<br/> Inherits GH_Component<br/> Public Reslist As New List(Of String)<br/> Public Sub New()<br/> MyBase.New("BrepDeform", "Deform", _<br/> "移动物件的控制点" & vbCrLf & "(Move the control Point to change a object)", "SEG", "Modify")</p>
<p>End Sub<br/> Public Overrides ReadOnly Property ComponentGuid As System.Guid<br/> Get<br/> Return New Guid("8226e0ea-ed6b-47c2-8a24-244f044152d8")<br/> End Get<br/> End Property<br/> Protected Overrides ReadOnly Property Internal_Icon_24x24() As System.Drawing.Bitmap<br/> Get<br/> Return My.Resources.SEG_BrepDeform<br/> End Get<br/> End Property<br/> Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_Component.GH_InputParamManager)<br/> ' pManager.AddTextParameter("Guid", "Id", "将要被替换的犀牛物件" & vbCrLf & "(RhinoObjects that will be replaced)", GH_ParamAccess.item)<br/> 'Dim guidParam As New Param_Guid<br/> pManager.AddParameter(New Param_Guid, "Guid", "Id", "将要被替换的犀牛物件" & vbCrLf & "(RhinoObjects that will be replaced)", GH_ParamAccess.item)<br/> pManager.AddPointParameter("ControlPoint3d", "C", "控制点的位置" & vbCrLf & "(Control Point's location)", GH_ParamAccess.item)<br/> pManager.AddPointParameter("NewPoint3d", "P", "新控制点的位置" & vbCrLf & "(New Control Point's location)", GH_ParamAccess.item)<br/> pManager.AddNumberParameter("Tolerace", "T", "输入点与物件实际控制点对比的精度" & vbCrLf & "(Tolerace for the Control Point match)", GH_ParamAccess.item, 0.1)</p>
<p>pManager.AddBooleanParameter("BlMove", "M", "如果是True则进行移动" & vbCrLf & "(If true Perform the Move)", GH_ParamAccess.item, False)</p>
<p>End Sub<br/> Protected Overrides Sub RegisterOutputParams(ByVal pManager As Kernel.GH_Component.GH_OutputParamManager)<br/> pManager.AddTextParameter("Result", "RG", "结果列表" & vbCrLf & "(Result)", GH_ParamAccess.list)<br/> End Sub<br/> Public Overrides ReadOnly Property Exposure As GH_Exposure<br/> Get<br/> Return GH_Exposure.primary<br/> End Get<br/> End Property</p>
<p>Protected Overrides Sub SolveInstance(ByVal DA As Kernel.IGH_DataAccess)<br/> If Banner.astrict.showmessage Then Return<br/> Dim Ids As Guid = Guid.Empty<br/> 'Dim Ids As String = String.Empty<br/> Dim tpt As Point3d = Point3d.Unset, opt As Point3d = Point3d.Unset<br/> Dim tolar As Double = 0.1<br/> Dim blMove As Boolean = False<br/> If Not DA.GetData(0, Ids) Then Return<br/> If Not DA.GetData(1, opt) Then Return<br/> If Not DA.GetData(2, tpt) Then Return<br/> If Not DA.GetData(3, tolar) Then Return<br/> If Not DA.GetData(4, blMove) Then Return<br/> If Not blMove Then<br/> GoTo line1<br/> Reslist.Add(Now & "_未替换!(Replace failed!)")<br/> Else<br/> Reslist.Clear()<br/> ' Grasshopper.Instances.ActiveCanvas.ModifiersEnabled = False<br/> End If</p>
<p>' rt.AddRange(docobjlist.Select(Function(geoobj As RhinoObject) GH_Convert.ObjRefToGeometry(New ObjRef(geoobj.Id))))<br/> 'Private Checked(5) As Boolean, Namestr() As String = {"Point", "Curve", "Brep", "Mesh", "TextDot", "TextEntity"}</p>
<p>Try</p>
<p>Dim rh As RhinoDoc = Rhino.RhinoDoc.ActiveDoc<br/> Dim rhobj As RhinoObject = rh.Objects.Find(Ids)<br/> ' Dim rhobj As RhinoObject = rh.Objects.Find(New Guid(Ids))</p>
<p>Dim bobj As BrepObject = CType(rhobj, BrepObject)<br/> RhinoApp.RunScript("Cancel", False)<br/> RhinoApp.RunScript("Cancel", False)<br/> bobj.Select(True)</p>
<p>RhinoApp.RunScript("_SolidPtOn", False)<br/> Dim gobjs As GripObject() = bobj.GetGrips<br/> ' rh.Views.RedrawEnabled = False<br/> For Each grpobj As GripObject In gobjs</p>
<p>If grpobj.CurrentLocation.DistanceTo(opt) < tolar Then<br/> grpobj.Select(True)<br/> Dim CurrentPln As Plane = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane<br/> Dim tropt As New Point3d(opt), trtpt As New Point3d(tpt)<br/> tropt.Transform(Transform.PlaneToPlane(Plane.WorldXY, CurrentPln))<br/> trtpt.Transform(Transform.PlaneToPlane(Plane.WorldXY, CurrentPln))</p>
<p>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)<br/> RhinoApp.RunScript(movestr, True)<br/> grpobj.Select(False)<br/> End If</p>
<p>Next</p>
<p>'RhinoApp.RunScript("Cancel", False)<br/> 'RhinoApp.RunScript("Cancel", False)<br/> '' rh.Views.RedrawEnabled = True<br/> Reslist.Add(Now & "_替换成功!(Replace Success!)")<br/> Catch ex As Exception<br/> Reslist.Add(Now & "_替换失败!(Replace failed!)" & vbCrLf & ex.Message)</p>
<p>End Try<br/> ' Grasshopper.Instances.ActiveCanvas.ModifiersEnabled = True</p>
<p>line1: DA.SetDataList(0, Reslist)<br/> End Sub</p>
<p>'Private Sub Testt_PingDocument(sender As IGH_DocumentObject, e As GH_PingDocumentEventArgs) Handles Me.PingDocument<br/> ' Dim Mbool = Aggregate bcbool In Checked Into cb = Any(bcbool)</p>
<p>' If Not Mbool Then<br/> ' Checked(0) = True<br/> ' Message = Namestr(0)<br/> ' Order = 0<br/> ' End If<br/> 'End Sub</p>
<p>End Class</p>
</div>
<p></p>
<p>The picture below shows the two question.</p>
<p></p>
<p></p>
<p></p>
<p></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769002605?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769002605?profile=RESIZE_1024x1024" width="721" class="align-left"/></a></p>
<p></p>
<p>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</p>
<p>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. </p>
<p>I don't know if I have made my question clear,if not give a message. Thank you! Thank you all.</p>
<p>The gh test file and 3dm test file in the upload files.</p>
<p></p> OK,I guessed the result. I ho…tag:www.grasshopper3d.com,2015-06-03:2985220:Comment:13015882015-06-03T09:31:23.725Zhuaxiamengqinghttps://www.grasshopper3d.com/profile/huaxiamengqing
<p>OK,I guessed the result. I hope it can be exposed in the sdk soon.</p>
<p>Now, I will use userdicionary to store the brep's verterPoints to solve My Problem.</p>
<p>Thank you!</p>
<p>OK,I guessed the result. I hope it can be exposed in the sdk soon.</p>
<p>Now, I will use userdicionary to store the brep's verterPoints to solve My Problem.</p>
<p>Thank you!</p> I'm pretty sure brep point de…tag:www.grasshopper3d.com,2015-06-03:2985220:Comment:13017362015-06-03T06:50:27.647ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
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).<br />
<br />
Or otherwise convert the brep to a set of polyline boundaries, deform those, then somehow patch it back together...<br />
<br />
Not ideal solutions but I can't think if a better way.
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).<br />
<br />
Or otherwise convert the brep to a set of polyline boundaries, deform those, then somehow patch it back together...<br />
<br />
Not ideal solutions but I can't think if a better way.