Parts List - Retrieve Diameter of Circular Plates

Parts List - Retrieve Diameter of Circular Plates

Anonymous
Not applicable
1,089 Views
12 Replies
Message 1 of 13

Parts List - Retrieve Diameter of Circular Plates

Anonymous
Not applicable

Hi,

 

I want to know how to retrieve diameter of circular metal plates. I can retrieve plate dimensions for rectangular plates without any problem as follows: PLATE 3 THK 100 x 150. But for circular plates I cannot display same as rectangular plates. I need to write an ilogic to display circular plates dimensions as follows: PLATE 2 THK ø 100 and also like that PLATE 2 THK OD 250 x ID 50. And also an ilogic code so that it can detect whether the part is circular or rectangular and then execute the according code.

 

Thanks,

Anas.

0 Likes
1,090 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable

Attached below is a Cylinder Template that I created for this exact situation.  Run the PartiProperty rule I attached in another of your forum posts.

 

Build the Plate from the given plane.

0 Likes
Message 3 of 13

WCrihfield
Mentor
Mentor

Are you wanting to run the solution code from a drawing document then, right?  And the model file within the drawing is an assembly, right?

I assume you have a custom column within your Parts List where you intend to show the physical size of the the rows part, right?  Do you want this information to be a Custom iProperty?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 13

Anonymous
Not applicable

Yeah I need an ilogic to retrieve the diameters(outer and inner) from the part file itself, because I want if I make changes to the part later, it autimatically updates in the parts list. I have a custom column to display the physical size.  

0 Likes
Message 5 of 13

Anonymous
Not applicable

I do not quite understand what you advised me to do. Can you explain to me more in details? Thanks.

 

Anas.

0 Likes
Message 6 of 13

Anonymous
Not applicable

I'll just attach the code here as well.

 

If you use the template I posted earlier an build the plate based off of the visible plane and then run the code it will fill in the "Description" field of the iProperties with the Diameter and Length.

0 Likes
Message 7 of 13

Anonymous
Not applicable

ok , I will try it and let you know.

0 Likes
Message 8 of 13

J-Camper
Advisor
Advisor

If you have parameters for the dimensions you want to extract, you can expose them as iProperties and then right a formula in another iProperty that references them, which gets automatically updated. If you reuse parts, the parameters will stay exposed as you copy them to new files.

 

Now there isn't any way to manually expose a parameter, but this rule will help you get them exposed:

Sub Main
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then Exit Sub
Dim openDoc As PartDocument = ThisApplication.ActiveDocument

'Option 1 load parameters into list to pick from. 
Dim ParamsList As New List(Of String)
For Each p As Parameter In openDoc.ComponentDefinition.Parameters
	ParamsList.Add(p.Name)
Next
If ParamsList.Count < 1 Then Exit Sub
'User selects a parameter to expose
UserInput = InputListBox("Select a Parameter to Expose As iProperty", ParamsList, ParamsList.Item(1), Title := "Expose a Paramter", ListName := "Available Paramters")
If IsNothing(UserInput) Then Exit Sub
	
Call Formatting(openDoc, UserInput) 

iLogicVb.UpdateWhenDone = True
End Sub

Sub Formatting(oDoc As PartDocument, oParam As String)
	Dim oP As Parameter= oDoc.ComponentDefinition.Parameters.Item(oParam)
	oP.ExposedAsProperty = True
'Custom Property Formtting Options:
	oFormat=oP.CustomPropertyFormat
	oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
	oFormat.Units = oP.Units
'	oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kTwoDecimalPlacesPrecision
'	oFormat.ShowUnitsString = False
'	oFormat.ShowLeadingZeros = False
'	oFormat.ShowTrailingZeros = True
			
	oDoc.Rebuild
End Sub

Exposed Parameters will appear in the Custom tab of the iProperties, and in the Parameters list there will be an extra option when right clicked: "Custom Property Format" [which can be set from the rule above with the commented out options or manually after exposing].

 

Then it as easy as writing an equation in the desired iProperty that references the custom ones.

Example:

Parameters that were exposed: "OD", "ID", "Thickness"

Description iProperty: "=Plate at <Thickness> has Diameters: <OD> & <ID>"

0 Likes
Message 9 of 13

Anonymous
Not applicable

Hi,

 

Thanks. I tried it and it worked. I will see in what way I can implement it in my parts.

 

Anas.

0 Likes
Message 10 of 13

WCrihfield
Mentor
Mentor

@J-Camper 

There IS a manual way to expose Parameters as custom iProperties.

Within the Parameters dialog, simply click the check box in the column labeled "Export Parameter" for the parameter you want to expose.  This is available in all model type documents, usually right next to the "Key" column.

And the rest of the additional formatting is also available manually.

Once you have checked the box in that Export column, just right click on the parameters row, then choose "Custom Property Format...".

The only types of parameters you can't manually expose this way right now are Text type and Boolean type parameters, but they can easily be exposed by code.

Also, within the context of a drawing document, the export column is not there, but it is there within Parts and Assemblies.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 13

WCrihfield
Mentor
Mentor

Here is some simple code that will expose every Text type and Boolean type UserParemeter as a Custom iProperty.

Dim oDocType As DocumentTypeEnum = ThisApplication.ActiveDocumentType
Dim oParams As Parameters
'Check document type, customize definitions to suit type, then either continue or exit if wrong type.
If oDocType = DocumentTypeEnum.kPartDocumentObject Or _
	oDocType = DocumentTypeEnum.kAssemblyDocumentObject Then
	oParams = ThisApplication.ActiveDocument.ComponentDefinition.Parameters
ElseIf oDocType = DocumentTypeEnum.kDrawingDocumentObject Then
	oParams = ThisDrawing.Document.Parameters
End If
Dim oUParams As UserParameters = oParams.UserParameters

'Iterate through all UserParameters, looking for Text type & Boolean type.
'When found, create identical Custom iProperties
For Each oUParam As UserParameter In oUParams
	If oUParam.Units = "Text" Then
		iProperties.Value("Custom", oUParam.Name) = oUParam.Value
	ElseIf oUParam.Units = "Boolean" Then
		iProperties.Value("Custom", oUParam.Name) = oUParam.Value
	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 12 of 13

Anonymous
Not applicable

Thanks. I will implement it and see how it works.

0 Likes
Message 13 of 13

J-Camper
Advisor
Advisor

@WCrihfield,  Thanks for letting me know, I had no idea that marking it for export would expose it as an iProperty.

0 Likes