I want to find the "exposed" surface area of my assembly. Doing some searching, it seems that the "AssemblyDocument.ComponentDefinition.MassProperties.Area" will give the total area of the assembly. ( I am not sure if this is just the sum of all the parts or if this is actually the exposed surfaces.)
I am wanting to write this to a variable using iLogic and then print it to the screen just so I can tell if its what I want or not. Having trouble doing that.
Here is the code I have so far. There is a problem on line 10 (Reference to a non-shared member requires an object reference). I can't figure out what I am doing wrong, but it is probably really simple for someone that knows squat about iLogic.
'Dim oAsmDoc As AssemblyDocument
'oAsmDoc = ThisApplication.ActiveDocument
'current document
doc = ThisDoc.Document
'unit manager of the document
oUOM = doc.UnitsOfMeasure
'get the value of Area
'surfaceArea = iProperties.Area
surfaceArea = AssemblyDocument.ComponentDefinition.MassProperties.Area
'round the value with 4 valid numbers (optional)
surfaceArea = Round(surfaceArea, 4)
'convert the value to a string with the unit of the document
surfaceArea = surfaceArea.ToString() + " " + oUOM.GetStringFromType(oUOM.LengthUnits) + "^2"
'update the custom property "Area" we created
'iProperties.Value("Custom", "Area") = surfaceArea
MessageBox.Show("Total Surface Area in SQ IN = " &surfaceArea,"Exterior Surface Area")
Any help greatly appreciated.
Kirk
Things to consider: - Values pulled from Inventor are always database units, so care and often unit conversions are required to work with values in the unit you want.
- VBA and VB.net provide access to methods and properties through OBJECTS. ie; [OBJECT].Method or [OBJECT].Property
- Objects are only accessed in very few ways:
- Assigning an object to another variable object; ie; oAsmDoc = ThisApplication.ActiveDocument
- PreExisting Objects ie; VBA.Len()
- New Objects ie; oInvApp = CreateObject("Inventor.Application")
- iLogic 'bastardizes' this in a way by providing many objects without having to think where they come from; ie; iProperties("Project", "Description") is actually a short version for saying [ApplicationObject].[Document Object].PropertySets("Design Tracking Properties")("Description").Value
- What this comes down to is that you should always know exactly what object you are wanting to point to/what object is returned whenever you see the ".".
- Why it didnt work for you - What specific object is just "AssemblyDocument" supposed to refer to? As you see in the first line, AssemblyDocument is actually a type and doesn't point to a specific object; just what kind of object it is. However, in the step below, ThisApplication is a pre-existing object that refers to the instance of the Inventor Application the rule is run in, which is why we can call it.
- In your snippet, you called Round() which is actually a short version of VBA.Round(). We don't need to specify VBA because it is the default object assigned to a method/property without the object indicated.
SyntaxEditor Code Snippet
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument 'unit manager of the document oUOM = oAsmDoc.UnitsOfMeasure surfaceArea = oAsmDoc.ComponentDefinition.MassProperties.Area MsgBox(oUOM.ConvertUnits(surfaceArea, "cm^2", "in^2") & " in^2")
Thanks for helping with the code. However, that does not report what I was hoping. There might not be a way to do this.
Take the assembly shown below.
This block measures 12in x 12in x 4.5in thick. For the exposed surface area, it calculates to be 504in^2. (144 front face, 144 back face, 54 on each edge face). In the inventor iproperties it reports 1080 in^2 for the area. This is the total area of each of the individual pieces (360in^2 x 3 pieces).
Is there a way to get the exposed surface area?
Thanks,
Kirk
As far as I know there is no way to directly get exposed area.
But in this case you can simply get it if you create derived component and measure its total area.
@Anonymous wrote:
As far as I know there is no way to directly get exposed area.
But in this case you can simply get it if you create derived component and measure its total area.
I am aware of that, but I am trying to automate the process. My ultimate goal is to have the exposed area shown on an idw
Thanks
Can't find what you're looking for? Ask the community or share your knowledge.