Insert ACAD File into Sketch API

Insert ACAD File into Sketch API

Anonymous
Not applicable
529 Views
1 Reply
Message 1 of 2

Insert ACAD File into Sketch API

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
530 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

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

0 Likes