Inventor Customization

Reply
Contributor
nathans222
Posts: 15
Registered: ‎12-25-2007
Message 1 of 8 (369 Views)

Minimum distance

369 Views, 7 Replies
04-01-2008 11:37 PM
can anyone tell me the code to find minimum distance between two faces using "Minimum distance" method...

Sainath K
Contributor
nathans222
Posts: 15
Registered: ‎12-25-2007
Message 2 of 8 (369 Views)

Re: Minimum distance

04-02-2008 01:08 AM in reply to: nathans222
anyway.. i got it now...
but can anyone tell me how to change the button event for custom toolbars...

coz in addins we are not specifying which event to consider... by default its taking button.execute as click event
Distinguished Contributor
ADNpati
Posts: 125
Registered: ‎07-01-2012
Message 3 of 8 (303 Views)

Re: Minimum distance

11-04-2012 03:49 PM in reply to: nathans222

Hello Nathan,

 

can you please paste code.. I need help in with minimum distance logic.

 

Is there anyway that we can get min distance in X,Y and Z directions??

 

thanks in Advance.

 

Cheers.

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
ADN Support Specialist
Vladimir.Ananyev
Posts: 475
Registered: ‎08-14-2012
Message 4 of 8 (277 Views)

Re: Minimum distance

11-12-2012 12:32 PM in reply to: ADNpati

Create two workpoints in your part "P1" and "P2".

 

Then the distance between these points can be calculated using MinimumDistance method.

Try this iLogic rule:

 

D = Measure.MinimumDistance("P1", "P2")

MsgBox(D)

 

In assembly you may use this method to get the minimal distance between two occurrences.

 

See Inventor API Help for MeasureTools object description.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
ADNpati
Posts: 125
Registered: ‎07-01-2012
Message 5 of 8 (271 Views)

Re: Minimum distance

11-12-2012 02:07 PM in reply to: Vladimir.Ananyev

Hi Vladmir,

 

Creation of pointts will disturb the geometry and structure of the modeled part. 

 

I am looking to get minimum distance from face to workpoint. 

 

please find the attachment, can see what i am talking about.

 

Much appriciated for solution.

 

Thank you.

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
ADN Support Specialist
Vladimir.Ananyev
Posts: 475
Registered: ‎08-14-2012
Message 6 of 8 (252 Views)

Re: Minimum distance

11-13-2012 08:28 AM in reply to: ADNpati

In my previous post I used workpoints only as one possible variant of measured objects.

MeasureTools.GetMinimumDistance method works with many entity types:

Part Face, Edge, Vertex, work features, 2d and 3d sketch entities Assembly FaceProxy, EdgeProxy, VertexProxy, work features and their proxies, 2d and 3d sketch entities and their proxies, ComponentOccurrences and their proxies Drawing DrawingViewCurve, GeometryIntent, 2d sketch entities.

See MeasureTools object detailed description in Inventor API Help.

 

You need to get the reference to the desired Face to be able to measure the distance to the workpoint.

Which method do you use?

 

In the following VBA sample I get this reference from the first element in the active assembly  SelectSet object.

The name of component (BOX) and the name of workpoint (P1) are hardcoded.

Change them to appropriate values.

Important note:  in assembly context SelectSet always returns proxy objects.

 

Private Sub MinDistance_1()

  Dim oAssyDoc As AssemblyDocument
  Set oAssyDoc = ThisApplication.ActiveDocument

  Dim oAssyDef As AssemblyComponentDefinition
  Set oAssyDef = oAssyDoc.ComponentDefinition
  
  '1) get the reference to the workpoint "P1"
  '   in the component "BOX"
  Dim oOcc As ComponentOccurrence
  Set oOcc = oAssyDef.Occurrences.ItemByName("BOX")
  
  Dim oDef As PartComponentDefinition
  Set oDef = oOcc.Definition
  
  Dim oWP As WorkPoint
  Set oWP = oDef.WorkPoints.Item("P1")
  
  'create work point proxy object
  Dim oWPproxy As WorkPointProxy
  Call oOcc.CreateGeometryProxy(oWP, oWPproxy)
  
  
  '2) get the reference to the selected face
  
  Dim oSSet As SelectSet
  Set oSSet = oAssyDoc.SelectSet
  
  If oSSet.Count = 0 Then
    MsgBox "Select some face"
    Exit Sub
  End If
  
  Dim oObj As Object
  Set oObj = oSSet.Item(1)
  
  If Not (TypeOf oObj Is FaceProxy) Then
    MsgBox "Select some face"
    Exit Sub
  End If

  Dim oFaceProxy As FaceProxy
  Set oFaceProxy = oObj
  
  '3) Measurements
  Dim oMeasureTools As MeasureTools
  Set oMeasureTools = ThisApplication.MeasureTools
  
  Dim D As Double ' distance (cm)
  D = oMeasureTools.GetMinimumDistance(oFaceProxy, oWPproxy)
  
  MsgBox ("D, cm = " & FormatNumber(D, 3))

End Sub 'MinDistance_1

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
rschader
Posts: 251
Registered: ‎12-15-2003
Message 7 of 8 (11 Views)

Re: Minimum distance

08-22-2014 09:56 AM in reply to: Vladimir.Ananyev

Just getting into iLogic these days, and I thought it would be a great way for me to update Tooling ball tags with the XYZ coordinate info. I used to have a macro (well, still do), but I figure I could eliminate it completely if I could do the same in iLogic. However, I seem to have run into a snag. Using iLogic's MinimumDistance function, I get the numbers I want, EXCEPT they do not specify if they are positive or negative distances (they are all positive), but the coordinates I put on my tooling ball labels must reflect their actual position in space. So does anyone know how I can find if these numbers should be positive or negative?

 

Here is what I am using so far:for my rule:

Parameter("TBLABEL #1 NH:1", "XDIST") = Measure.MinimumDistance("YZ Plane", "TOOLING_BALL_1")
Parameter("TBLABEL #1 NH:1", "YDIST") = Measure.MinimumDistance("XZ Plane", "TOOLING_BALL_1")
Parameter("TBLABEL #1 NH:1", "ZDIST") = Measure.MinimumDistance("XY Plane", "TOOLING_BALL_1")

In the case of my test environment, all the numbers should be negative, but that will vary.

Thanks in advance!

Bob

Distinguished Contributor
rschader
Posts: 251
Registered: ‎12-15-2003
Message 8 of 8 (6 Views)

Re: Minimum distance

08-22-2014 10:51 AM in reply to: rschader

OK, I found another thread that helped me get what I am looking for, although I'm probably cheating by just mulitplying the XYZ values by 10 to get them into millimeters!

Here is what I got now:

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oWorkPoint As WorkPoint
'set workpoint to TOOLING_BALL_1

oWorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("TOOLING_BALL_1")
Parameter("TBLABEL #1 NH:1", "XDIST")=oWorkPoint.Point.X * 10.0
Parameter("TBLABEL #1 NH:1", "YDIST")=oWorkPoint.Point.Y * 10.0
Parameter("TBLABEL #1 NH:1", "ZDIST")=oWorkPoint.Point.Z * 10.0
Parameter("TBLABEL #1 NH:1", "LABEL") = "TOOLBALL"
Parameter("TBLABEL #1 NH:1", "LABEL_NUM")="1"

oWorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("TOOLING_BALL_2")
Parameter("TBLABEL #2 NH:1", "XDIST")=oWorkPoint.Point.X * 10.0
Parameter("TBLABEL #2 NH:1", "YDIST")=oWorkPoint.Point.Y * 10.0
Parameter("TBLABEL #2 NH:1", "ZDIST")=oWorkPoint.Point.Z * 10.0
Parameter("TBLABEL #2 NH:1", "LABEL") = "TOOLBALL"
Parameter("TBLABEL #2 NH:1", "LABEL_NUM")="2"

oWorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("TOOLING_BALL_3")
Parameter("TBLABEL #3 NH:1", "XDIST")=oWorkPoint.Point.X * 10.0
Parameter("TBLABEL #3 NH:1", "YDIST")=oWorkPoint.Point.Y * 10.0
Parameter("TBLABEL #3 NH:1", "ZDIST")=oWorkPoint.Point.Z * 10.0
Parameter("TBLABEL #3 NH:1", "LABEL") = "TOOLBALL"
Parameter("TBLABEL #3 NH:1", "LABEL_NUM")="3"

 

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 or visit the Installation and Licensing Forum to get help installing your software.