Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Line + ExtrudeFeatures.AddByDistanceExtent VB.net or vba

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
mario.lung
744 Views, 6 Replies

Line + ExtrudeFeatures.AddByDistanceExtent VB.net or vba

Hi,

 

i wanna making a extrusion from every select line in Part

 

/code

 

Public Sub test()

 

Dim oPartdoc As PartDocument

Set oPartdoc = ThisApplication.ActiveDocument

 

Dim oCompDef As PartComponentDefinition

Set oCompDef = oPartdoc.ComponentDefinition

 

Dim oSelectSet As SelectSet

Set oSelectSet = oPartdoc.SelectSet

 

If oSelectSet.Count = 0 Then

   Exit sub

end if

 

    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.item(1)

 

    Dim oSketchLine As SketchLine
    Set oSketchLine = oSelectSet.item(1)

 

    Dim oSketch As Sketch
    Set oSketch = oSketchLine.Parent

    Dim oProfile As Profile

 Set oProfile = oSketch.Profiles.AddForSurface

 

 Dim oCutExtrude As ExtrudeFeature

 Set oCutExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, 1, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection, PartFeatureOperationEnum.kSurfaceOperation)

 

end sub

 

/code

 

so this code dosent work any one can help me please

 

thx

 

 

6 REPLIES 6
Message 2 of 7
xiaodong_liang
in reply to: mario.lung

Hi,

 

It is not clear to me why you re-defined oSketch. So I just commented out one definition

 


   ' Dim oSketch As PlanarSketch
   ' Set oSketch = oCompDef.Sketches.Item(1)

 

    Dim oSketchLine As SketchLine
    Set oSketchLine = oSelectSet.Item(1)

 

    Dim oSketch As Sketch
    Set oSketch = oSketchLine.Parent

 

And I selected any sketch line in one sketch, run your code, the result works fine to me. Please see the attached screenshot.

 

 

 

Best regards,

 
autodesk_logo_signature.png

Xiaodong Liang

Developer Consultant

Autodesk Developer Technical Services

Message 3 of 7
mario.lung
in reply to: mario.lung

Hi,

 

thx for your help because its not working right

 

create 2 lines select the last create line and start the code

you can see now it makes the extrusion always on the first inserted line 😞 and not on the selected secound line 😞

 

thx

 

Mario

 

Message 4 of 7
mario.lung
in reply to: mario.lung

I Solved the Problem now with

 

 

    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSurface(oSketchLine)

 thx

Message 5 of 7
akosi
in reply to: xiaodong_liang

how can i activate sketch command in vba?

 

i want to add a projected line from a face i will select.

 

thanksSmiley Happy

 

 

Message 6 of 7
mario.lung
in reply to: akosi

Hi,

 

you mean this?

as example

 

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

' Create the new sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition
Set oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Add("Faltmarken_A1")

Dim oSketch As DrawingSketch
Call oSketchedSymbolDef.Edit(oSketch)

 

cu

Mario

Message 7 of 7
akosi
in reply to: mario.lung

i need the code for ipt or iam to create a projected line from a solid.

 

executing the sketch command is good enough for me.

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

Post to forums  

Autodesk Design & Make Report