Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Rotate Existing Curve Object w/ API

Anonymous

Rotate Existing Curve Object w/ API

Anonymous
No aplicable

I having a bit of difficulty trying to rotate an existing curve object from the API. The FMCurves object has a reference to a method "XFormRotate" containing the same arguments found in the UI Transform dialog box used to rotate it from FeatureCAM. At the time of this transformation, there is only one existing curve in the document. Document.curves.Item(1).Name returns the name of my only curve, so I know the object isn't null, but when I try to run Document.curves.XFormRotate, nothing happens. Any ideas?

 

Thanks

0 Me gusta
Responder
Soluciones aceptadas (1)
632 Vistas
4 Respuestas
Respuestas (4)

klaus.gibbe
Autodesk
Autodesk

I think you have to select the curve first.
Rotation is applied to all selected object.

...curve.select(true, true)

 

0 Me gusta

Anonymous
No aplicable

I still cant get anything to rotate. See simple code below:

Sub Main

	Dim app As Application
	Dim doc As FMDocument

	Set app = Application
	Set doc = app.ActiveDocument

	'made a simple curve within the turning document for rotation around Y axis
	doc.curves.Item(1).Select(True, True)
	doc.curves.XFormRotate(False, False, 0, 90, eXFT_RotateCenterYAxis)


End Sub

The select in this case works. I tried multiple variations of the xFormRotate method including:

doc.curves.Selected.XFormRotate(....)
doc.Features.XFormRotate(...)
doc.Features.Selected.XFormRotate(...)

No such luck. 

0 Me gusta

klaus.gibbe
Autodesk
Autodesk
Solución aceptada

There are several possibilities to do the rotation.

 

a)

select to objects you want to rotate by curves/models/features.item(i).select(true, false) and then rotate all selected objects in a document by

doc.XFormRotate(...)

 

or b)

select object(s) of a specific type like curve.select(true, false) and rotate all selected curves only by

doc.curves.Selected.XFormRotate(...)

 

 

One other thing to think about is the position of the rotation axis. You want to rotate around Y axis.

Where is the origin of the rotation axis?
Maybe you should do something like this:

doc.XFormRotate(false,false,0,angle,eXFT_RotateCenterYAxis, posX, 0, posZ,null)

where posX/Z is the origin of the y axis.

 

 

 

0 Me gusta

Anonymous
No aplicable

The origin axis as 0,0,0 is something i tried before. The thing that i changed was the exclusive parameter of the Select method to false and that seemed to work. For reference:

Sub Main

	Dim app As Application
	Dim doc As FMDocument

	Set app = Application
	Set doc = app.ActiveDocument

	'made a simple curve within the turning document for rotation around Y axis
	doc.curves.Item(1).Select(True, False)
	doc.curves.Selected.XFormRotate(False, False, 0, 90, eXFT_RotateCenterYAxis, 0,0,0)


End Sub

Thanks for your help!

0 Me gusta