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: 

Create Warehouse and insert columns using ilogic

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
murugasubi
373 Views, 2 Replies

Create Warehouse and insert columns using ilogic

Hi Dear, Please refer the attached inventor sketch which is a warehouse, and inside dots are columns. I am copying the sketch from AutoCAD and pasting it in inventor. Now, I want to create the warehouse after that I need columns as per the attached final image. Below is the ilogic code for creating a warehouse. I want to create the columns, Please help me with the balance code to create columns.  (if column creation is not possible, we can insert the columns in the points also ok)

 

'Creating warehouse without columns

Sub main
    Dim oPartDoc As PartDocument
    oPartDoc = ThisApplication.ActiveDocument
                 
    ' Set a reference to the component definition.
    Dim oCompDef As PartComponentDefinition
    oCompDef = oPartDoc.ComponentDefinition
    
   'Dim oSketches As PlanarSketches = ThisApplication.ActiveEditDocument.ComponentDefinition.Sketches
	'oSketches("Sketch1").Edit
	
	Dim oSketches As PlanarSketches = oCompDef.Sketches
	'oSketches("WHBaseSketch").ExitEdit
	Try
		oSketches("WHBaseSketch").ExitEdit
	Catch
		
	End Try
	
	Dim oSketch1 As PlanarSketch
	oSketch1 = oSketches("WHBaseSketch")
	
	' Create a profile.
    Dim oProfile As Profile
    oProfile = oSketch1.Profiles.AddForSolid
    
    ' Create a base extrusion 1cm thick.
    Dim oExtrudeDef As ExtrudeDefinition
    oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
    Call oExtrudeDef.SetDistanceExtent(1, kNegativeExtentDirection)
    Dim oExtrude As ExtrudeFeature
    oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
	
	Dim oFrontFace As Face
    oFrontFace = oExtrude.StartFaces.Item(1)
	
	Dim oSketch2 As PlanarSketch

	If False Then
	    oSketch2 = oCompDef.Sketches.Add(oFrontFace)

	    Dim featEdge As Edge
	    For Each featEdge In oFrontFace.Edges
	        Call oSketch2.AddByProjectingEntity(featEdge)
	    Next
	Else
	    'Simpler version
	    oSketch2 = oCompDef.Sketches.Add(oFrontFace, True)
	End If

	Dim entitiesForOffset As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
	entitiesForOffset.Add(oSketch2.SketchLines(1))

	Dim offsetDistance As Double '= 12 '* 2.54
	offsetDistance = 12 * 2.54
	Dim offsetDirection As Boolean = True
	Dim offsetedEntities = oSketch2.OffsetSketchEntitiesUsingDistance(entitiesForOffset, offsetDistance, offsetDirection, True, True)

	Dim profile2 = oSketch2.Profiles.AddForSolid(True)
	Dim oExtrudeDef2 = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(profile2, PartFeatureOperationEnum.kJoinOperation)
	Call oExtrudeDef2.SetDistanceExtent(60*2.54, kPositiveExtentDirection)
	Dim oExtrude2 = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef2)
	
	ThisApplication.CommandManager.ControlDefinitions("AppIsometricViewCmd").Execute
	
End Sub

'I need to insert / craete columns on the points

Thanks
Murugan

  

2 REPLIES 2
Message 2 of 3
aelqabbany
in reply to: murugasubi

Add this to the bottom of your code and let me know how it goes:

 

	
	ThisApplication.CommandManager.ControlDefinitions("AppIsometricViewCmd").Execute
	
	ColumnsCounter = 0
	ColumnX = 20
	ColumnY = 40
	ColumnHeight = 500
	For Each oSPoint As SketchPoint In oSketch1.SketchPoints
		If oSPoint.AttachedEntities.Count = 0 Then 
			ColumnsCounter += 1
			Dim ColumnSketch As PlanarSketch = oCompDef.Sketches.Add(oFrontFace)
			Dim InstanceSketchPoint As SketchPoint = ColumnSketch.AddByProjectingEntity(oSPoint)
			Dim RectanglePoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(InstanceSketchPoint.Geometry.X + ColumnX, InstanceSketchPoint.Geometry.Y + ColumnY)
			ColumnSketch.SketchLines.AddAsTwoPointCenteredRectangle(InstanceSketchPoint, RectanglePoint)
			Dim ColumnProfile As Profile = ColumnSketch.Profiles.AddForSolid
			Dim ColumnExtrudeDef As ExtrudeDefinition = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(ColumnProfile, kjoinoperation)
			ColumnExtrudeDef.SetDistanceExtent(ColumnHeight , kPositiveExtentDirection)
			Dim ColumnExtrude As ExtrudeFeature = oCompDef.Features.ExtrudeFeatures.Add(ColumnExtrudeDef)
			ColumnExtrude.Name = "Column" & Str(ColumnsCounter)
		End If
	Next

 

Message 3 of 3
murugasubi
in reply to: murugasubi

Thanks a lot, @aelqabbany 

I have checked with many sketches, all are working excellent. I really appreciate your efforts and heartfelt thanks to you. You have saved a lot of time for us on sketch editing.

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

Post to forums  

Autodesk Design & Make Report