- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Everybody
Have you ever met the error with ThickenFeature in Inventor
I have created code to thicken faces that I selected before
But in the new part file, the code is very normal and work well
But when I open 1 part file (which created it by Making a component from the MultiSolid part file) the code just can create the first thicken face, it met the error for the second and stop the code for the first time I run code in that part file for the first time. When I that code for the second time, it works normally.
Does anyone have experience with my issue?
If you help any ideas, please help me
I also attach my code here so you guys can know my code
foreach (Face face in laminate)
{
FaceCollection FacesCol = default(FaceCollection);
FacesCol = _invApp.TransientObjects.CreateFaceCollection();
FacesCol.Add(face);
oThickFeat = partDef.Features.ThickenFeatures.Add(FacesCol, laminate_thick.Text + "mm", PartFeatureExtentDirectionEnum.kNegativeExtentDirection, PartFeatureOperationEnum.kNewBodyOperation, false, false, false);
oThickFeat.SurfaceBody.Name = "Laminate " + i.ToString();
oThickFeat.Name = "Thicken_Laminate " + i.ToString(); ;
}
Thank you so much and hope someone can help me!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I had a very similar error with the thicken feature, the difference is I was creating the faces also using code that is being used for thicken. Can you also explain when you are iterating through for loop what is "laminate"? is it a solid body or a feature? If you can send the file in which it works with your code and also the file in which it does not work maybe I can check if it is suitable.
I am not good with C#, but I have created the code long back in VB.Net where I was iterating through features and then finding a feature, that is a surface extrude, before iterating to the faces, I have cleared the object collection that is created (so that it will not try to thicken the face that is already thickened, try this I think that will do the trick) and I have added the counter, which is used for naming the thicken features. See below code for reference and see if it helps.
FCount = 1 Dim oFaceCol As FaceCollection oFaceCol = ThisApplication.TransientObjects.CreateFaceCollection For Each oFeat As PartFeature In oDef.Features If oFeat.Name.Contains("Partition") oFaceCol.Clear For Each oFace In oFeat.SurfaceBodies.Item(1).Faces Call oFaceCol.Add(oFace) Dim oThickFeat As ThickenFeature oThickFeat = oDef.Features.ThickenFeatures.Add(oFaceCol, "4",kSymmetricExtentDirection,kNewBodyOperation,False) oThickFeat.Name = "Thicken-Partition" & FCount FCount = FCount +1 Next End If Next
If this has answered your question, please accept it as a solution.
Regards,
Dutt Thakar.
Regards,
Dutt Thakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Very thanks for your reply
Actually, Laminate is just a name I put for the new solid and the thicken feature
You can also check my attached IPT file (This file works when I create a new Part file, not a part created by Make Components)
Here is the error in Visual Studio when I have a problem in using code
Note: The code will work if it is a new Part file
The code will have trouble if it is a part created by Make Components
The code will have trouble if use code in the ActiveEdit Document in Assembly Environment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for sending the part. I did a small test in iLogic, see below code. I also have attached a screencast to show you that it is creating thicken in the derived part.
Dim oDef As PartComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition Dim oSB As SurfaceBody = oDef.SurfaceBodies.Item(1) ' This is first solid after derive "Laminate" MessageBox.Show(oSB.Name) Dim oThickFeat As PartFeature i = 1 For Each oFace As Face In oSB.Faces Dim oFaceCol As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection oFaceCol.Clear oFaceCol.Add(oFace) oThickFeat = oDef.Features.ThickenFeatures.Add(oFaceCol, "5", kSymmetricExtentDirection, kNewBodyOperation, False) oThickFeat.Name = "Laminate" & i i = i + 1 Next
If this has answered your question, please accept this as a solution.
Regards,
Dutt Thakar
Regards,
Dutt Thakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @dutt.thakar
Thank you for your devoted reply
I will check again, and notice you if my problem still occurs
Note: Actually, in my case, I will not thicken all the face of solid, just faces that I select by Pick method before
Anyway, thank you so much, I will try your advise
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @dutt.thakar
Thank you for your advice
But the problem still occurs although I use exactly your code
In my case, I do not Derive the part as your video
I use thicken code for the part created by the Make Component function
Do you have know for my case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can you take the face object collection creation out of the loop and check? try below code. I have crated a new part using make components and tried this rule and it works fine.
Dim oDef As PartComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition Dim oSB As SurfaceBody = oDef.SurfaceBodies.Item(1) ' This is first solid after derive "Laminate" MessageBox.Show(oSB.Name) Dim oFaceCol As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection Dim oThickFeat As PartFeature i = 1 For Each oFace As Face In oSB.Faces oFaceCol.Clear oFaceCol.Add(oFace) oThickFeat = oDef.Features.ThickenFeatures.Add(oFaceCol, "5", kSymmetricExtentDirection, kNewBodyOperation, False) oThickFeat.Name = "Laminate" & i i = i + 1 Next
Hope it helps.
Regards,
Dutt Thakar
Regards,
Dutt Thakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try this code which allows you to select the faces first and then when you run the rule it will only thicken those which are selected. You can select one or multiple faces. Make sure you select the faces first and then only run the rule. If you get an error, try to comment the last line in the loop which is renaming thicken features, because if you run again and you have the same names it may result in an error.
Dim oDef As PartComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition Dim oSB As SurfaceBody = oDef.SurfaceBodies.Item(1) ' This is first solid after derive "Laminate" MessageBox.Show(oSB.Name) Dim oThickFeat As PartFeature Dim oFaceCol As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection i = 1 Dim oSS As SelectSet = ThisApplication.ActiveDocument.SelectSet For Each oFace As Face In oSS oFaceCol.Clear oFaceCol.Add(oFace) oSS.SelectMultiple(oFaceCol) oThickFeat = oDef.Features.ThickenFeatures.Add(oFaceCol, "5", kSymmetricExtentDirection, kNewBodyOperation, False) oThickFeat.Name = "Laminate" & i i = i + 1 Next
See if it works.
Regards,
Dutt Thakar
Regards,
Dutt Thakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @dutt.thakar
Thank you for your code
I also tried it, but in your way, you use VBA and I-Logic in Inventor to run the code
But in my way, I use API (code with Visual Basic), so maybe it also the reason for it
I include the lick for the video in which I record the error when using the Thicken feature
Hope through this video you can have a new idea for my problem
Inventor API - Thicken Error
Thank you so much @dutt.thakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @dutt.thakar
Thank you for your help in recent days
With your help, I also found the solution to my problem
Now it can work normally when I run the code
Thank you so much