Use value of particular dimension in drawing ilogic rule

Use value of particular dimension in drawing ilogic rule

Anonymous
Not applicable
319 Views
2 Replies
Message 1 of 3

Use value of particular dimension in drawing ilogic rule

Anonymous
Not applicable

Hi experts, 🙂

 

One of the ilogic rule for drawing I've been working on requires to use dimension value from one end to COG. I need to use this dimension as integer value further in my rule. Means when my assembly model gets updated, correct COG dimension should be generated in my rule.

 

Basically my question is how to use any dimensional value of drawing in ilogic rule ?

 

Any sort of help would be appreciated.

Thanks in advance guys 🙂

 

@peter.hamas @johnsonshiue @chandra.shekar.g @Ralf_Krieg @bradeneuropeArthur 

0 Likes
320 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Can you include more detail about what you are trying to accomplish and/or what you are asking?  Maybe include some screen captured images as visual aid.  If you need help doing something by code, maybe include a bullet point list of actions you are trying to do by code.

Right now, I'm guessing you want to be able to make parameter/constraint type changes within your assembly document, then get instant feedback from a specific drawing dimension on a specific sheet within the associated drawing document to help you determine if the changes you are making within the assembly are having the desired effect/result?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

Here is a fairly basic iLogic rule code example that is designed to be ran from the 'active' assembly document.  It immediately attempts to find/get the associated drawing document.  Then attempts to get the sheet, the dimension, and the dimension's model value.  There are a lot of assumptions involved in this code, so it very likely won't work for you without any changes, but it lays out the logical process you would have to go though by code to retrieve a drawing dimension's value from an assembly document.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("An Assembly Document must be active for this rule to work as designed. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oPath As String = System.IO.Path.GetDirectoryName(oADoc.FullFileName)
Dim oDirSep As Char = System.IO.Path.DirectorySeparatorChar
Dim oName As String = System.IO.Path.GetFileNameWithoutExtension(oADoc.FullFileName)

'assumes drawing file has same path and name, but different file extension
'assumes drawing is IDW, not DWG file type
Dim oDDoc As DrawingDocument
Try
	oDDoc = ThisApplication.Documents.ItemByName(oPath & oDirSep & oName & ".idw")
Catch
	oDDoc = ThisApplication.Documents.Open(oPath & oDirSep & oName & ".idw", True)
Catch
	MsgBox("Couldn't find/open the drawing document.  Exiting.", , "")
	Exit Sub
End Try

'specify which sheet within the drawing to target
'assuming the target dimension is on the first sheet of that drawing
Dim oSheet As Inventor.Sheet = oDDoc.Sheets.Item(1)

'specify which dimension on the sheet to target
'assumes you just want to target the first dimension placed on the sheet
Dim oDim As DrawingDimension = oSheet.DrawingDimensions.Item(1)

'get the dimension's model value
Dim oVal As Double = oDim.ModelValue

'check it, and do something in responce to its value
If oVal < 1 Then
	MsgBox("The value is less than one.", , "")
ElseIf oVal >= 1 And oVal <= 25 Then
	MsgBox("The value is between 1 and 25.", , "")
ElseIf oVal > 25 Then
	MsgBox("The value is greater than 25.", , "")
End If

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes