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: 

iLogic in IPT file to Insert Sketch Blocks

8 REPLIES 8
Reply
Message 1 of 9
ComputerGuru666
1448 Views, 8 Replies

iLogic in IPT file to Insert Sketch Blocks

Ok basically I have an IPT file with a few different 2d sketch blocks I also have a 2d Sketch called "Profile" basically what you would do is edit the "Profile" sketch and Place Block selecting what ever profile you needed to extrude (Square Tube, Angle, Plate,Pin, Round Tube) Im looking for a way to do this with ilogic so far Ive been able to activate the "Profile" Sketch and delete the current block thats placed in the sketch but when I try to insert a new block the code errors out. see code below

 

 

 

Dim oPartDoc As PartDocument

oPartDoc = ThisApplication.ActiveDocument

Dim oCompDef As PartComponentDefinition

oCompDef = oPartDoc.ComponentDefinition

Dim oSketches As PlanarSketches

oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches

Dim oSketch As PlanarSketch

oSketch = oSketches.Item("Profile")

oSketch.Edit

oSketch.sketchblocks.item(1).delete

Dim oSketchBlockDef As SketchBlockDefinitions

oSketchBlockDef = oCompDef.SketchBlockDefinitions.Item("Plate") 

This is where it errors out stating "The Parameter is incorrect" (See attached picture for a screenshot of the "More Info section of the Error Message)
Dim oPosition As Point2d oPosition = ThisApplication.TransientGeometry.CreatePoint2d(0, 0) ' Insert the sketch block definition oSketch.SketchBlocks.AddByDefinition(oSketchBlockDef, oPosition) oSketch.exitedit
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
8 REPLIES 8
Message 2 of 9

Hi ComputerGuru666,

 

I think the issue is that the block called Plate has no internal profiles where as the the tube profiles do, and visa versa. Can you confirm this?

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 3 of 9

Hi Curtis 

 

In short Im nottrying to select Inventor profiles Im trying to select blocks that I created

 

I've drawn these profiles myself and added them to the "Blocks" Folder in the IPT so when I activate the 2d sketch named "Profile" I can then Right Click on "Plate" or "Circle" (or any other block I might add) under the "Blocks" folder and click "Place Block" which then allows me to place the block I chose in that sketch finish editing the sketch and extrude that sketch see attached picture.

 

 

 

Hope this makes sense

 

 

Thank you

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
Message 4 of 9

Hi ComputerGuru666,

 

I think I follow what you're doing, but I get an error if I try to exchange a block with an internal profile with one that has only one (external) profile, or visa versa.

 

For instance if I try to exchange a block with a rectangle profile with one that has a circle, it works. If I try to exchange the rectangle profile with a tube profile, I get the error.

 

I think the solution will be the Combine parameter of the Profiles.AddForSolid method, but I'm not certain.

 

Do you get errors exchanging blocks that have the same number of profiles? Or only when one block has a different number of profiles?

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Parameters 
Description 
Combine 
Optional input Boolean that specifies whether to combine the profile paths obtained when this method is used to create a new profile. For instance, let us take the example of a sketch containing two concentric circles. If this argument is specified to be true, the resulting profile will contain 2 profile paths, and the profile path corresponding to the inner circle will have its AddsMaterial flag set to False. Hence, the resulting profile is a circular disc with a circular cut-out. If the Combine flag is specified to be False, the resulting profile will contain 2 profile paths with the AddsMaterial flag set to True for both paths. If the sketch contains text boxes, then the profile paths corresponding to them will always have the AddsMaterial flag set to True irrespective of whether the Combine flag is specified to be True or False.
Message 5 of 9

Ahh We are getting closer I have fixed the parameter issue however now Im getting a new error when I switch the profile with the ilogic the ilogic properly deletes the existing block in the sketch and then errors out (see attachment)

 

however if i manually activate the sketch delete whatever block is used for the extruded profile and place a different block and click finish sketch the extrusion updates without issue except if like you said I try to go from a plate to a tube profile.

 

 

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
Message 6 of 9

Ok I have solved the above problem but I am still working on the issue of switching between the tube profile and the plate profile any ideas?

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
Message 7 of 9

Hi,

 

I did not see a description on the question "switching between the tube profile and the plate profile" in this thread. Could you elaborate?

Message 8 of 9
Anonymous
in reply to: ComputerGuru666

Can you provide an explination for the solution that you found ComputerGuru666?  I'm trying to get this to work and running into the same issue you're describing.

 

Thanks.

Shane

Message 9 of 9

I figured out how to change the profiles from a plate to a tube with out anything erroring out here is the code using part of Curtis Waguespacks "selecting all closed profiles code" and making a few small changes and adding a few things so the code would select the extruded feature and then update the new 2d profile for that extruded feature 

        If ProfileType = "" Then
            'Do Nothing            
            Else
            
            'Suppress extruded feature            Feature.IsActive("Extruded Profile") = False
            
            Dim oPartDoc As PartDocument
            oPartDoc = ThisDoc.Document
            
            Dim oCompDef As PartComponentDefinition
            oCompDef = oPartDoc.ComponentDefinition
            
            Dim oSketches As PlanarSketches
            oSketches = oCompDef.Sketches
            
            Dim oSketch As PlanarSketch
            oSketch = oSketches.Item("Profile")
            
            oSketch.Edit
            
            oSketch.sketchblocks.item(1).delete
            
            Dim oSketchBlockDef As SketchBlockDefinition
            oSketchBlockDef = oCompDef.SketchBlockDefinitions.Item(ProfileType) 'multivalue list only containing the names of all blocks            
            oPosition = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
            
            oSketch.SketchBlocks.AddByDefinition(oSketchBlockDef, oPosition)
            
            oSketch.exitedit
            
            Feature.IsActive("Extruded Profile") = True
            
'updates the extrusions profile after the the sketch has been changed Dim oExtrude As ExtrudeFeature oExtrude = oCompDef.Features.ExtrudeFeatures.Item("Extruded Profile") 'get the feature Dim oProfile As Profile oProfile = oSketch.Profiles.AddForSolid 'get the profile loops and save to oProfile oExtrude.Profile = oProfile 'update the profile definition for oExtrude oPartDoc.Update 'update the doc End If
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

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

Post to forums  

Autodesk Design & Make Report