Inventor Customization

Reply
Active Contributor
ComputerGuru666
Posts: 39
Registered: ‎06-18-2010
Message 1 of 4 (220 Views)

iLogic Change Extrude Profile *Help*

220 Views, 3 Replies
12-03-2012 02:10 PM

Ok I am trying to program an iLogic code that does the following

 

Prompts user to select Square or Round Pin

 

Then Askes the user for the sizes 

 

Square Pin

Length

Width

Height

 

Round Pin 

Diameter

Height

 

Where Height is the extrude length 

 

What ever done is created a 2d Sketch with a square and circle in it and it extruded it Now if the user selects Square pin

By Default Diameter will be set to 0in

and 

Length = 1

Width = 1

 

The problem Im having is that if the user goes back and decideds it needs to be a round pin the sketch changes but the extruded feature errors out because the profile changed

 

Does anyone know how I can update the profile of the extrusion? Ive tried this code but the problem Im getting is that once the extrusion is deleted it does rename the new extrusion "extrude1" which means should the user want to change the pin from square to round multiple times the code will only find ExtrudeFeatures("Extrude1") Once and error our should the user try to change it again. And no creating 2 different extrusions and just supressing 1 depending on the selection it out of the question. Thank you

 

    Dim oPartDoc As PartDocument
    oPartDoc = ThisApplication.ActiveDocument
    
    Dim oCompDef As PartComponentDefinition
    oCompDef = oPartDoc.ComponentDefinition
    
    Call oCompDef.Features.ExtrudeFeatures("Extrude1").Delete(True, True)
    
    
    Dim oSketch As PlanarSketch
    oSketch = oCompDef.Sketches("Sketch1")
   
    Dim oProfile As Profile
    oProfile = oSketch.Profiles.AddForSolid
    
    oDistance = Height
    oJoinOrCut = kJoinOperation
    oDirection = kSymmetricExtentDirection
    
    Dim oExtrude As ExtrudeFeature

    oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent( _
    oProfile, oDistance, oDirection, oJoinOrCut)

 

 

Computer Specs:
Windows 7 (64 Bit) Pro. SP1, Inventor 2014 Pro, 3D Connexion SpaceNavigator (Driver 3.15.2)
Motherboard: ASUS Rampage IV Extreme x79 Socket 2011
Processor: Intel Core i7 Six Core Sandy Bridge-E 3.2GHz OCed to 4.7GHz (Under Water)
RAM: G.Skill Ripjaw Z-Series 32 gig quad channel of RAM 1800MHz OCed to 2133MHz
Video Card: 2x Nvidia Geforce GTX 770 (Running Six (6) Monitors)
Monitors: [Primary = 2x 24in HD WS][Secondary = 2x 22in HD WS][Tertiary = 2x 19in FS]
Primary Hard Drive: OCZ Vertex IV 256 GB Solid State Drive
Secondary Hard Drive: OCZ Vertex III 120 GB Solid State Drive
Distinguished Contributor
thomaskennedy
Posts: 112
Registered: ‎09-27-2010
Message 2 of 4 (212 Views)

Re: iLogic Change Extrude Profile *Help*

12-04-2012 01:43 AM in reply to: ComputerGuru666

If your sketch always has a rectangle and a circle drawn, this should work for you :

 

'get user input
extrudeshape = InputBox("Circle or Square?", "Circle or Square?", "Square")

' Get the active part document
Dim oPartDoc As PartDocument = ThisDoc.Document

' Get comp definition
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

' Get the existing sketch with square and circle
Dim oSketch As PlanarSketch = oCompDef.Sketches.Item("Sketch1")

' get transient geometry object.
Dim oTransGeom As TransientGeometry = ThisApplication.TransientGeometry

' get reference to existing feature
Dim oExtrude As ExtrudeFeature = Feature.InventorFeature("Extrusion2")

' create an object collection
Dim oPathSegments As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

'sketch lines (for rectangle), sketch circles (for circle)
Dim oLines As SketchLine
Dim oCircles As SketchCircle

'based on the user input, get :
'
- All of the sketch LINES in the sketch
'
OR
'
- All of the sketch CIRCLES in the sketch
'
- NOTE, you need to update the document when changing to the circle from 0 diameter.

If extrudeshape = "Square" Then
'get the rectangle

For Each oLines In oSketch.SketchLines
oPathSegments.Add(oLines)
Next
Parameter("dia") = 0

Else If extrudeshape = "Circle" Then
'get the circle
Parameter("dia") = 50
InventorVb.DocumentUpdate()

For Each oCircles In oSketch.SketchCircles
oPathSegments.Add(oCircles)
Next

End If

'create the new profile - could be a circle or square
oProfile = oSketch.Profiles.AddForSolid(False, oPathSegments)

' give the extrusion the new profile
oExtrude.Profile = oProfile

 

The extrusion profile will change dependant on the users answer.

 

(You may need to tidy it up to get it working for your situation)

 

Cheers,

Tom

Active Contributor
ComputerGuru666
Posts: 39
Registered: ‎06-18-2010
Message 3 of 4 (195 Views)

Re: iLogic Change Extrude Profile *Help*

12-11-2012 02:02 PM in reply to: thomaskennedy

No not exactly here is some more code I used a square and circle as an example in the first post because those were 2 of the 5 different profiles all in "Sketch1" basically if the user selects plate the code needs to set intial values for the 2d sketch of the plate and set all the other dimensions for the other profiles in Sketch1 to 0 (zero). The below code does this perfectly the problem Im having is that If I change from Plate to Pin the extruded profile doesnt update it errors out but the sketch changes from a square to a circle, the other problem Im having is because I set the parameters to an initial number if I try to change them in my Form (Example the plates initiall values 1 x 2 x 3, and I need to change it to 1 x 6 x 12 but when I type in the new number in the form for that parameter (which drives the dimension on the sketch) it just reverts back to the intial value) hope this makes some sense

 

MultiValue.SetList("ModelType", "Pin", "Plate", "Angle", "Round Tube", "Square Tube")
MultiValue.UpdateAfterChange = (True)
MultiValue.SetValueOptions(True)


If ModelType = "Angle" Then

'Angle Parameters
LLeg = 4
SLeg = 2
AngWt = .25
'Plate Parameters
PWidth = 0
PHeight = 0
'Pin Parameters
PDia = 0
'Round Tube Parameters
ODia = 0
RndWt = 0
'Square Tube Parameters
SQWidth = 0
SQHeight = 0
SQTWt = 0
'Common Parameters (Extrusion)
'Length = 2

ElseIf ModelType = "Plate" Then

'Angle Parameters
LLeg = 0
SLeg = 0
AngWt = 0
'Plate Parameters
PWidth = 2
PHeight = 1
'Pin Parameters
PDia = 0
'Round Tube Parameters
ODia = 0
RndWt = 0
'Square Tube Parameters
SQWidth = 0
SQHeight = 0
SQTWt = 0
'Common Parameters (Extrusion)
Length = 3

ElseIf ModelType = "Pin" Then

'Angle Parameters
LLeg = 0
SLeg = 0
AngWt = 0
'Plate Parameters
PWidth = 0
PHeight = 0
'Pin Parameters
PDia = .5
'Round Tube Parameters
ODia = 0
RndWt = 0
'Square Tube Parameters
SQWidth = 0
SQHeight = 0
SQTWt = 0
'Common Parameters (Extrusion)
Length = 2


ElseIf ModelType = "Round Tube" Then

'Angle Parameters
LLeg = 0
SLeg = 0
AngWt = 0
'Plate Parameters
PWidth = 0
PHeight = 0
'Pin Parameters
PDia = 0
'Round Tube Parameters
ODia = 2
RndWt = .125
'Square Tube Parameters
SQWidth = 0
SQHeight = 0
SQTWt = 0
'Common Parameters (Extrusion)
'Length = 2

ElseIf ModelType = "Square Tube" Then

'Angle Parameters
LLeg = 0
SLeg = 0
AngWt = 0
'Plate Parameters
PWidth = 0
PHeight = 0
'Pin Parameters
PDia = 0
'Round Tube Parameters
ODia = 0
RndWt = 0
'Square Tube Parameters
SQWidth = 2
SQHeight = 2
SQTWt = 0.095
'Common Parameters (Extrusion)
'Length = 2

End If

 

Hope someone can make sense of this and thanks for the help so far

 

Computer Specs:
Windows 7 (64 Bit) Pro. SP1, Inventor 2014 Pro, 3D Connexion SpaceNavigator (Driver 3.15.2)
Motherboard: ASUS Rampage IV Extreme x79 Socket 2011
Processor: Intel Core i7 Six Core Sandy Bridge-E 3.2GHz OCed to 4.7GHz (Under Water)
RAM: G.Skill Ripjaw Z-Series 32 gig quad channel of RAM 1800MHz OCed to 2133MHz
Video Card: 2x Nvidia Geforce GTX 770 (Running Six (6) Monitors)
Monitors: [Primary = 2x 24in HD WS][Secondary = 2x 22in HD WS][Tertiary = 2x 19in FS]
Primary Hard Drive: OCZ Vertex IV 256 GB Solid State Drive
Secondary Hard Drive: OCZ Vertex III 120 GB Solid State Drive
ADN Support Specialist
adam.nagy
Posts: 521
Registered: ‎03-26-2007
Message 4 of 4 (164 Views)

Re: iLogic Change Extrude Profile *Help*

01-09-2013 10:26 AM in reply to: ComputerGuru666

Happy New Year!

 

If you are still having issues with this then the best would be if you could create a new document from scratch that is as simple as possible but enough to reproduce the issue.

Then also provide the exact steps we need to follow to reproduce the problem.

 

Thank you,



Adam Nagy
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube