# Drag and transform subobjects

**URL:** <https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448>\
**Category:** Rhino Developer\
**Tags:** subobject\
**Created:** [September 14, 2017, 8:10am UTC](https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448 "2017-09-14T08:10:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gennaro](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gennaro/32/175042_2.png) [@gennaro](https://discourse.mcneel.com/u/gennaro)\
**Post date:** [September 14, 2017, 8:10am UTC](https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448/1 "2017-09-14T08:10:23Z")

</div>

Hi everybody!  
I have been struggling trying to emulate with C++ SDK the functionality Rhino has to select, drag and transform subobjects (e.g. to move an edge/face of a brep and adapt the entire object according to the new edge/face position).  
 ![Untitled](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/3/a/3af0f0342a4ba62459f243c47ebfb0727b2e360f.png)  
I wonder if I have to reassembly the object “manually” or if there is an SDK function.  
Any clue??  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [September 14, 2017, 9:16pm UTC](https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448/2 "2017-09-14T21:16:39Z")

</div>

Hi @gennaro,

All of that fanciness eventually calls [ON\_TransformBrepComponents](http://4.rhino3d.com/5/rhinocppsdk/ON_TransformBrepComponents@ON_Brep_@int@ON_COMPONENT_INDEX_@ON_Xform@double@double@bool.html).

– Dale

---

<div class="post-metadata">

**Author:** ![gennaro](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gennaro/32/175042_2.png) [@gennaro](https://discourse.mcneel.com/u/gennaro)\
**Post date:** [October 18, 2017, 8:15pm UTC](https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448/3 "2017-10-18T20:15:54Z")

</div>

Brilliant! Thanks!!

---

<div class="post-metadata">

**Author:** ![gennaro](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gennaro/32/175042_2.png) [@gennaro](https://discourse.mcneel.com/u/gennaro)\
**Post date:** [September 26, 2018, 4:09pm UTC](https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448/4 "2018-09-26T16:09:32Z")

</div>

Hi!  
I am trying to use this function to drag the subcomponents of a brep:

```
ON_Xform translateXform;
translateXform.TranslationTransformation(ON_3dVector(10,1,1));
if (brep) {
	ON_Brep * dupBrep = brep->Duplicate();
	if (dupBrep) {
		ON_TransformBrepComponents(dupBrep, subidxs.Count(), subidxs, translateXform, 0.01, 2, true);
		CRhinoBrepObject * new_object = new CRhinoBrepObject();
		new_object->SetBrep(dupBrep);
		if (new_object) {
			::RhinoApp().ActiveDoc()->ReplaceObject(pObject, *dupBrep);
		}
	}
}

```

the problem is that it crashes sometimes. My guess is that it happens when the brep is not valid. The problem is that Rhino is capable to move the subcomponent dragging it with the mouse! Why the function is not capable then? (on Rhino6)

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [September 26, 2018, 8:24pm UTC](https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448/5 "2018-09-26T20:24:31Z")

</div>

Hi @gennaro,

Does `RhinoTransformBrepComponents` work any better? Also, make to check the return value.

– Dale

---

<div class="post-metadata">

**Author:** ![gennaro](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gennaro/32/175042_2.png) [@gennaro](https://discourse.mcneel.com/u/gennaro)\
**Post date:** [October 2, 2018, 11:28am UTC](https://discourse.mcneel.com/t/drag-and-transform-subobjects/47448/6 "2018-10-02T11:28:12Z")

</div>

it seems to work!  
thanks!
