SetBaseQuantity to m^2

SetBaseQuantity to m^2

CadUser46
Collaborator Collaborator
1,084 Views
6 Replies
Message 1 of 7

SetBaseQuantity to m^2

CadUser46
Collaborator
Collaborator

Hi.

 

I know this is unsupported but before you write me off please make sure im doing this right.  I have it working for EACH and Meter but this gives me an error on the last line.

 

Private Sub SetUnitsSQMTR()

    Dim oApp As Inventor.Application: Set oApp = ThisApplication
    Dim oPart As Inventor.PartDocument: Set oPart = oApp.ActiveDocument

    'EACH
    Dim oBU As BOMQuantity: Set oBU = oPart.ComponentDefinition.BOMQuantity

    'Get the document UnitOfMeasure object to facilitate unit conversions
    'Dim uom As UnitsOfMeasure: Set uom = oPart.UnitsOfMeasure

    'Get the parameter
    Dim oParam As Parameter
    Set oParam = oPart.ComponentDefinition.Parameters("G_L")
    oParam.ExposedAsProperty = True
    oParam.Units = "m^2"
    oParam.Expression = "0.001 m^2"
    
    'Set the QtyType
    Dim oType As BOMQuantityTypeEnum: oType = kParameterBOMQuantity
    
    'set BaseQty
    Call oPart.ComponentDefinition.BOMQuantity.SetBaseQuantity(oType, oParam)

End Sub

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
1,085 Views
6 Replies
Replies (6)
Message 2 of 7

CadUser46
Collaborator
Collaborator

bump


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 3 of 7

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

These two things seem to me conflicting: "I know this is unsupported" <> "please make sure im doing this right"

It is indeed unsupported so it would be better not to try to hack the system:

 

BomBaseQuantity.png

You can work around this in the UI, but not sure what issues it could cause down the line.

 

Cheers,

 



Adam Nagy
Autodesk Platform Services
0 Likes
Message 4 of 7

CadUser46
Collaborator
Collaborator

Hi Adam

 

Firstly I meant, is this the correct method if it was 'm' or 'ft'?  It works, I just want to be sure im doing it right.

 

Let me ask it another way.  What is the supported method for area? UI or otherwise.

 

Lastly it's not as simple as that.  I am aware of the behaviour in the UI but we need to use areas in Vault so want to migrate existing files based on their PLM uom.  Additionally the UI method is clunky so wish to automate that.

 

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes
Message 5 of 7

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

Area is not currently supported as a Base Unit for BOM. This has been logged on the IdeaStation - even though it has been accepted it could be useful to vote on it so that it will get implemented sooner:
http://forums.autodesk.com/t5/inventor-ideas/area-units-in-base-quantity/idi-p/4387795 

 

You can see the supported units in the dialog:

SupportedBaseUnit.png

 

As I said you can work around it but not sure if this will cause issues down the line 😕

1) create a parameter with a supported unit

2) set the BOM base unit to be based on this parameter

3) now change the unit of the parameter to an area type >> the BOM base unit will be the same
This thread seems to talk about it too: 
https://forums.autodesk.com/t5/inventor-ideas/square-feet-as-a-unit-of-measure-for-bom/idi-p/5484590

 

Note: in general, the API is there to automate things - if something is not possible in the product itself (in the UI) then it's not possible through the API either.

 

Cheers,

 



Adam Nagy
Autodesk Platform Services
0 Likes
Message 6 of 7

Scotty87
Contributor
Contributor

Hi,

 

I have a bit of a workaround method that I have implemented with a fair amount of success. The method goes as follows:

 

In your sheet metal template, create a user parameter called "Plate" and set the unit/type to "m"; I recommend setting the precision to 0.123 units. Then create a  rule (I call it "Plate Area") with the following code:

 

 

iProperties.Value("Custom", "FlatExtentsArea") = SheetMetal.FlatExtentsArea

Area = SheetMetal.FlatExtentsArea / 1000

iProperties.Value("Custom", "PlateArea") = iProperties.Value("Custom", "Area") & ""

iLogicVb.UpdateWhenDone = True

 

You will also need to create 2 custom iProperties: one called "Area" and the other called "Plate Area".

 

Don't worry about setting the BOM base qty.

 

Now for the drawing.

In the drawing template, go to Styles & Standards Editor > Parts List. Right-click > Format column on your Unit Qty column, click the Substitution tab and enable Value Substitution. Select "Plate Area" from the drop down.

 

You should now see the square metre value of your sheet metal components appear in the parts list.

The only problem that I have so far encountered using this method is that for section components (RHS, flat bar etc.), the units string must be specified in that components template, as applying units formatting to the parts list itself will not allow the square metre value to work. Shouldn't be an issue if your Content Centre files are set up properly, but otherwise you may get stuck with a whole bunch of trailing zeroes.

 

Hope this helps.

0 Likes
Message 7 of 7

CadUser46
Collaborator
Collaborator

I like your idea Scott and I will look further but I still don't think it solves my problem.  We need the Base Qty to match the PDM uom.  ie to get boms to work correctly in Vault we need the Base Qty in the file to match the Vault Item uom.  If anybody knows anyway at all to solve this problem then please let me know.

 

We have already added m^2, in^2, ft^2 as units in the Vault Settings as Inventor does not have the native 'Square Meter' units that Vault has.  For those using Vault Pro, how are you calculating area direct from CAD as we ultimately need to export the QTY field?


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
0 Likes