Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Embossing Feature - API

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Houston_Shimala
360 Views, 6 Replies

Embossing Feature - API

So I want to place a parameter into a sketch that will be embossed. Here's the problem, I got the code to do what i want but it places the parameter as a string instead of a parameter (because i want it to automatically update if i change that parameter). Any help would be greatly appreciated! Thank You! I can code in both vb.net and c# so you can use whatever you prefer, but here is my code:

 

Dim oPart As PartDocument = invApp.ActiveDocument 'resetting part document
Dim oDoc As Document = invApp.ActiveDocument
Dim oComponentDefinition As ComponentDefinition = oPart.ComponentDefinition

Dim oFace As Face = invApp.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a face")

Dim Sketch As PlanarSketch = oComponentDefinition.Sketches.Add(oFace, True)

Dim oTG As TransientGeometry
oTG = invApp.TransientGeometry


Dim oEdge As Edge
Dim oEdge2 As Edge
oEdge = invApp.CommandManager.Pick(SelectionFilterEnum.kPartEdgeMidpointFilter, "Pick Left Hand Edge")
oEdge2 = invApp.CommandManager.Pick(SelectionFilterEnum.kPartEdgeMidpointFilter, "Pick Bottom Edge")


Dim userParameters As UserParameters = oPart.ComponentDefinition.Parameters.UserParameters
Dim param As Parameter = userParameters.Item(1)


Dim oTextBox As Inventor.TextBox
oTextBox = Sketch.TextBoxes.AddFitted(oTG.CreatePoint2d((oEdge.PointOnEdge.X + oEdge2.PointOnEdge.X) / 2, (oEdge.PointOnEdge.Y + oEdge2.PointOnEdge.Y) / 2), param)

Dim oPaths As ObjectCollection
oPaths = invApp.TransientObjects.CreateObjectCollection
oPaths.Add(oTextBox)

Dim oProfile As Profile
oProfile = sketch.Profiles.AddForSolid(False, oPaths)

Dim oExtrudeDef As ExtrudeDefinition
oExtrudeDef = oComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, Inventor.PartFeatureOperationEnum.kCutOperation)
Call oExtrudeDef.SetDistanceExtent(0.25, Inventor.PartFeatureExtentDirectionEnum.kNegativeExtentDirection)
Dim oExtrude As ExtrudeFeature
oExtrude = oComponentDefinition.Features.ExtrudeFeatures.Add(oExtrudeDef)

6 REPLIES 6
Message 2 of 7

Hi! I think this is fairly easy to do. But, before you automate the process, you want to make sure it works manually. You still need a text parameter. Here is what you need to do. 

1) Go to Parameters table -> create a text parameter.

2) Create a sketch -> Text -> insert the text parameter to the sketch.

3) Create the Emboss feature based on the text.

 

Now if you change the text parameter, the Emboss feature will update accordingly.

Is this what you are looking for?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 3 of 7

Sure, that's how you do it in inventor. I would like to do it through code. 

 

(not making a parameter, assigning a parameter to a string)

 


@johnsonshiue wrote:

Hi! I think this is fairly easy to do. But, before you automate the process, you want to make sure it works manually. You still need a text parameter. Here is what you need to do. 

1) Go to Parameters table -> create a text parameter.

2) Create a sketch -> Text -> insert the text parameter to the sketch.

3) Create the Emboss feature based on the text.

 

Now if you change the text parameter, the Emboss feature will update accordingly.

Is this what you are looking for?

Many thanks!



@johnsonshiue wrote:

Hi! I think this is fairly easy to do. But, before you automate the process, you want to make sure it works manually. You still need a text parameter. Here is what you need to do. 

1) Go to Parameters table -> create a text parameter.

2) Create a sketch -> Text -> insert the text parameter to the sketch.

3) Create the Emboss feature based on the text.

 

Now if you change the text parameter, the Emboss feature will update accordingly.

Is this what you are looking for?

Many thanks!


 

Message 4 of 7
MjDeck
in reply to: Houston_Shimala

This is undocumented and I can't guarantee that it will continue to work in future versions of Inventor. But this should do it:

Change the last argument in the call to TextBoxes.AddFitted from param to param.Value

Add this statement after that:

oTextBox.FormattedText = String.Format("<Parameter Resolved='True' ComponentIdentifier='{0}' Name='{1}' Precision='3'>{2}</Parameter>", oDoc.FullFileName, param.Name, param.Value)

Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 7
Houston_Shimala
in reply to: MjDeck


@MjDeck wrote:

This is undocumented and I can't guarantee that it will continue to work in future versions of Inventor. But this should do it:

Change the last argument in the call to TextBoxes.AddFitted from param to param.Value

Add this statement after that:

oTextBox.FormattedText = String.Format("<Parameter Resolved='True' ComponentIdentifier='{0}' Name='{1}' Precision='3'>{2}</Parameter>", oDoc.FullFileName, param.Name, param.Value)

This is perfect but, using http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-915B75BA-4696-4fc7-A2C6-54B2BACDE7E1 as a reference, is it not possible to input a Design Tracking Property as a parameter? I also have not found a way to specifically convert a [Property](which is what you use for iproperties see code) into a parameter.

 

'Dim oPropSets As PropertySets
'oPropSets = oDoc.PropertySets


'Dim oPropSet As PropertySet
'oPropSet = oPropSets.Item("Design Tracking Properties")

'Dim param As [Property] = oPropSet.Item("Part Number") '<--- change this into a "Parameter"

Message 6 of 7

Nevermind,

 

I found a way around this.


@Houston_Shimala wrote:

@MjDeck wrote:

This is undocumented and I can't guarantee that it will continue to work in future versions of Inventor. But this should do it:

Change the last argument in the call to TextBoxes.AddFitted from param to param.Value

Add this statement after that:

oTextBox.FormattedText = String.Format("<Parameter Resolved='True' ComponentIdentifier='{0}' Name='{1}' Precision='3'>{2}</Parameter>", oDoc.FullFileName, param.Name, param.Value)

This is perfect but, using http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-915B75BA-4696-4fc7-A2C6-54B2BACDE7E1 as a reference, is it not possible to input a Design Tracking Property as a parameter? I also have not found a way to specifically convert a [Property](which is what you use for iproperties see code) into a parameter.

 

'Dim oPropSets As PropertySets
'oPropSets = oDoc.PropertySets


'Dim oPropSet As PropertySet
'oPropSet = oPropSets.Item("Design Tracking Properties")

'Dim param As [Property] = oPropSet.Item("Part Number") '<--- change this into a "Parameter"


 

Thank you for your help!

Message 7 of 7
MjDeck
in reply to: Houston_Shimala

You're welcome. And thanks for finding out that it actually is documented. I was wrong about that.


Mike Deck
Software Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report