- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
setting fastener size using API
Sub main()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oHoleF As HoleFeatures
Set oHoleF = oDoc.ComponentDefinition.Features.HoleFeatures
oHoleF.Item(3).ClearanceInfo.FastenerSize = "M10"
MsgBox (oHoleF.Item(3).ClearanceInfo.FastenerType)Hello, I am new to the API
through this code, I am trying to set the fastener size to be a specific value based on a specific parameter. the programming/API Help informed that the "FastenerSize" is a read-write property to set or get the fastener size so how can I use this method to set the fastener size, Although using this code introduces error for me " Run-time error 445, Object doesn't support this action".
noting that this is the only thing in the hole feature that will change as shown in the figure below and all other choices will be constant with a different configuration of the model.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
You have to create new HoleClearanceInfo and then replace target ClearanceInfo with new one.
Sub main()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oHoleF As HoleFeatures
Set oHoleF = oDoc.ComponentDefinition.Features.HoleFeatures
Dim oHole As HoleFeature
Set oHole = oHoleF.Item(3)
Dim oOriginal As HoleClearanceInfo
Set oOriginal = oHole.ClearanceInfo
Dim oChanged As HoleClearanceInfo
Set oChanged = oHoleF.CreateClearanceInfo(oOriginal.FastenerStandard, oOriginal.FastenerType, "M10", oOriginal.FastenerFitType)
oHole.ClearanceInfo = oChanged
MsgBox (oHoleF.Item(1).ClearanceInfo.FastenerType)
End SubSee also :
https://modthemachine.typepad.com/my_weblog/2019/07/new-apis-in-inventor-20201.html
Ah, it is written in the above blog that this API is added to Inventor 2020.1.
If you use Inventor 2019, it will be difficult to change the parameter...
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Thanks for your code.
yes, you are right!!, the code did not run.
But for beginner person like me, how Can I know that I need to construct a new clearance info.!!, I mean I did searching in the Inventor Programming help and no indication for this also, I used Watch window too and the type of massage error has no information.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
@mostafamahmoudseddek94 wrote:how Can I know that I need to construct a new clearance info.!!
Let's Google!!
https://www.google.com/search?q=HoleClearanceInfo+inventor
Or ask in this forum!
=====
Hideo Yamada