API: Creating extrude problem

API: Creating extrude problem

Jef_E
Collaborator Collaborator
1,298 Views
10 Replies
Message 1 of 11

API: Creating extrude problem

Jef_E
Collaborator
Collaborator

Hi all!

 

I have this new problem, i'm trying to create a Surface extrude from a Arc.

My sketch has 3 Arc, and then i select the first Arc in it. This is the one i need to Extrude. But somthing i wrong with my code.. Don't know where the error is, as I have never done a Extrude feature..

 

My sample code:

        Dim oDoc As PartDocument = oInvApp.ActiveDocument
        Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
        Dim oArc As SketchArc = oDef.Sketches.Item("Segm_C02").SketchArcs(1)

        Dim oExtrudeDef As ExtrudeDefinition
        oExtrudeDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oArc, PartFeatureOperationEnum.kSurfaceOperation)
        oExtrudeDef.SetDistanceExtent("1000", PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
        oDef.Features.ExtrudeFeatures.Add(oExtrudeDef).Name = "Extrude"

 

What do i need to change?

 



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Accepted solutions (1)
1,299 Views
10 Replies
Replies (10)
Message 2 of 11

MechMachineMan
Advisor
Advisor
What error are you getting? Screenshot of both windows can be useful for helping determine what is wrong.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 11

Jef_E
Collaborator
Collaborator

Hi,

 

Sorry for my late response.

 

This is the error i get on the posted code.

 

Can not convert COM object of type System .__ ComObject to interface type Inventor.Profile .
This operation failed because the QueryInterface call on the COM component for the interface with
IID { 8006A03A - ECC4-11D4-8DE9-0010B541CAA8 } failed with the
following error : No such interface supported (Exception from HRESULT: 0x80004002 ( E_NOINTERFACE ) ) .

Any ideas?



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 4 of 11

MechMachineMan
Advisor
Advisor
Your syntax is wrong you are doing the equivalent of trying to assign a
string to am integer. That's what 'casting' as worded in the error means.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 11

MechMachineMan
Advisor
Advisor
Your syntax is wrong you are doing the equivalent of trying to assign a
string to am integer. That's what 'casting' as worded in the error means.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 11

Jef_E
Collaborator
Collaborator

I don't get it.

 

the error is produced on this line:

oExtrudeDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oArc, PartFeatureOperationEnum.kSurfaceOperation)

But my oArc is as SketchArc? What is causing the error then? I don't see it..

 



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 7 of 11

MechMachineMan
Advisor
Advisor
Are you passing the function a closed loop? If you can't do it manually...
you can't do it with API.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 8 of 11

Jef_E
Collaborator
Collaborator

I can do i manually, thats why i want to automate it.

 

It's an arc that i want to extrude as surface, not as solid, so no it's not a closed loop.

I need this to create a thicken feature later in the program.

 

So i think for a surface i call

PartFeatureOperationEnum.kSurfaceOperation

But it's not working for me. 

 

Thanks for helping me!



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 9 of 11

MechMachineMan
Advisor
Advisor
How do you know for sure it's that line giving issue?

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 10 of 11

Anonymous
Not applicable

Well, i think so because it highlights in visual studio? 😄

 

It could be that it gets a bad input.. But what?

0 Likes
Message 11 of 11

Jef_E
Collaborator
Collaborator
Accepted solution

Found it, forgot to add for surface, didn't know that was needed. Will help me on my next step too!

 

Dim oSketch As PlanarSketch = oDef.Sketches.Item("Segm_C" & oBodyCount)
Dim oArc As SketchArc = oSketch.SketchArcs(1)
Dim oProfile As Profile = oSketch.Profiles.AddForSurface(oArc)

Dim oExtrudeDef As ExtrudeDefinition
oExtrudeDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kSurfaceOperation)

 

 

Thanks for the help!



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2