Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Access the freeform feature API

supriya_chaugule
Contributor

Access the freeform feature API

supriya_chaugule
Contributor
Contributor

Hiii.....I want to get the API to convert the solid face into FreeForm Feature.Can anyone help with the same?

 

supriya_chaugule_0-1686906103573.png

 

0 Likes
Reply
434 Views
5 Replies
Replies (5)

WCrihfield
Mentor
Mentor

Hi @supriya_chaugule.  I do not think there is any API code for that specific task.  There are API objects for FreeFormFeatures, FreeFormFeature, & FreeFormFeatureProxy, but no Add or Copy type method for creating new ones, or converting someting else to a FreeFormFeature.  So, the best I could come up with is some simple code that basically attempts to simulate the manual process, which is:  Pre-select all the faces of the body, then execute that convert command, then just simulate clicking the OK button, without specifying any options.  This worked OK for me in a simple block type part example.

Dim oPDoc As PartDocument = ThisDoc.Document
Dim oBody As SurfaceBody = oPDoc.ComponentDefinition.SurfaceBodies.Item(1)
Dim oFaces As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each oFace In oBody.Faces
	oFaces.Add(oFace)
Next
Dim oCDs As ControlDefinitions = ThisApplication.CommandManager.ControlDefinitions
Dim oCD1 As ControlDefinition = oCDs.Item("TSplineConvertToTSplineCmd")
Dim oCD2 As ControlDefinition = oCDs.Item("AppContextual_OKCmd")
oPDoc.SelectSet.SelectMultiple(oFaces)
oCD1.Execute
oCD2.Execute

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

supriya_chaugule
Contributor
Contributor

Hii @WCrihfield  I am able to get the edit option from command manager.But how can I get the control points or the faces from that freeform face. Here attaching the code.

 

public void freeFormSurface()
{
PartDocument oDoc = (PartDocument)mApplication.ActiveDocument;
SurfaceBody oBody = oDoc.ComponentDefinition.SurfaceBodies[1] as SurfaceBody;
ObjectCollection oFaces = mApplication.TransientObjects.CreateObjectCollection();

oFaces.Add(oBody.Faces[7]);
ControlDefinitions oCDs = mApplication.CommandManager.ControlDefinitions;
ControlDefinition oCD1 = oCDs["TSplineConvertToTSplineCmd"];
ControlDefinition oCD2 = oCDs["AppContextual_OKCmd"];

oDoc.SelectSet.SelectMultiple(oFaces);
oCD1.Execute();
oCD2.Execute();


ControlDefinition oCD3 = oCDs["FinishTSplineCmd"];
oCD3.Execute();

PartComponentDefinition compDef = oDoc.ComponentDefinition;

FreeformFeature ff = compDef.Features.FreeformFeatures[1];

 

ff.IsInEditMode= true;

}

 

supriya_chaugule_0-1687168061718.png

How do i get this control points from API?

0 Likes

Phuffakerson
Observer
Observer

That sounds like a fantastic forum for individuals interested in Inventor iLogic, API, and VBA programming! Having a dedicated platform to share knowledge, ask questions, and discuss topics related to programming, creating add-ins, macros, and working with the API or iLogic tools can be immensely valuable for both beginners and experienced users.

For those looking to expand their skills or solve specific challenges within Inventor, this forum provides an opportunity to interact with a community of like-minded individuals who share a passion for Inventor's automation capabilities. It creates a space where users can exchange ideas, share tips and tricks, and collaborate on various projects.

Being part of a forum dedicated to Inventor iLogic, API, and VBA can have several benefits. It allows users to:

0 Likes

WCrihfield
Mentor
Mentor

Although I pretty much never use FreeForm in my work, but I looked into this a little bit more today.  I still have not found a good way to get access or control the individual divider lines or interior vertexes of the FreeForm feature, while it is in edit mode.  There are likely several more obscure, specific commands for the tools involved in editing FreeFormFeatures, but executing commands by code is generally not a popular way of controlling that sort of thing, in favor of direct API objects and their methods, properties & such.  My guess it that they simply have not exposed that much functionality for accessing and controlling FreeForm related stuff in Inventor's API or iLogic yet.   It does not sound to me like an ability that would be in high demand by a lot of users, so it likely has not gotten as much API development as some of the other stuff.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

supriya_chaugule
Contributor
Contributor

Is there any other way where we can get the access of control points ? So we can use that for changing the shape of face or transform it in any direction.I want to do something like this 

supriya_chaugule_0-1687319236868.png

 

0 Likes