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: 

Insert ACAD File into Sketch API

1 REPLY 1
SOLVED
Reply
Message 1 of 2
thomaskennedy
415 Views, 1 Reply

Insert ACAD File into Sketch API

Hi all,

 

I've been doing some searching on these forums for an API to insert an ACAD file into a sketch.

Is there an API call to do this? I found that I can use the command manager with PostPrivateEvent :

 

oCmdMgr.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, sFileName)
oCmdMgr.ControlDefinitions("SketchInsertAutoCADFileCmd").Execute

 

It works great for my purpose BUT it doesn't auto constrain the endpoints, which is essential as I need to extrude /sweep after it has inserted.

There is an option to constrain end points when you manually do the import, but the command manager mustn't have anyaccess to options ?

 

So two questions I guess

 

1. Is there an API to insert an ACAD file into a sketch ?

2. If there isn't, is there another way to constrain the end points to make a loop after the insert?

 

Thanks,

Tom

 

ps. I'm using Inventor 2011

1 REPLY 1
Message 2 of 2

Well after a lot of trial and error I've finally got things working, I couldn't find an API for the ACAD insert so I had to stick with the CommandManager as above.

 

This is the code I'm using to constrain the endpoints in the sketch (uses the .Merge() method) :

 

Dim StartCounter As Integer
		Dim PointItemMaster As SketchPoint
		Dim PointItemClient As SketchPoint
		
		For Each PointItemMaster In oSketch.SketchPoints
			StartCounter = 0
			For Each PointItemClient In oSketch.SketchPoints
				If Round(PointItemClient.Geometry.x,4) = Round(PointItemMaster.Geometry.x,4) And Round(PointItemClient.Geometry.y,4) = Round(PointItemMaster.Geometry.y,4) Then
					StartCounter = StartCounter + 1
					
					If StartCounter = 2 Then
						PointItemMaster.Merge(PointItemClient)
						StartCounter = 0
						Exit For
					End If
				End If
			Next PointItemClient
		Next PointItemMaster

 

When I dumped out all the XY's for the sketch entities I found that for whatever reason some of them were out by 0.000000000000001 - hence the Round() on the sketchpoints (4 decimal places is plenty accurate for what I'm doing)

 

Thought I'd post in case someone has the same problem in the future.

 

Tom

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

Post to forums  

Autodesk Design & Make Report