Hello thanks for quick reply
I shall try to explain my case, we are a small machine shop
we use Fusion 360 on the cam side.
when I do quotation to apart
I need to know how big the stock is going to be, to get the price on the stock and the material.
so this is the main purpose on the application.
on the stock we need to make it a little bit bigger.
so this is why I want to be able to adjust the size.
and I figure I don't need to do the work two times
that's why I want the solid to represent the stock.
so basically I do all the prep in Inventor
then I don't need to do the work again Fusion 360 when I pushed apart to Fusion.
this is what I come up with so far.
but in the picture you can see the blue but it is only a visual representation and I can't adjust it.
and here is the code
' Get the current Part document.
Dim partDoc As PartDocument = ThisDoc.Document
' Get the TransientBRep and TransientGeometry objects.
Dim transBRep As TransientBRep = ThisApplication.TransientBRep
Dim transGeom As TransientGeometry = ThisApplication.TransientGeometry
' Combine all bodies in Part into a single transient Surface Body.
Dim combinedBodies As SurfaceBody = Nothing
For Each surfBody As SurfaceBody In partDoc.ComponentDefinition.SurfaceBodies
If combinedBodies Is Nothing Then
combinedBodies = transBRep.Copy(surfBody)
Else
transBRep.DoBoolean(combinedBodies, surfBody, BooleanTypeEnum.kBooleanTypeUnion)
End If
Next
' Get the oriented mininum range box of all bodies in Part.
' NOTE: "OrientedMinimumRangeBox" was added in Inventor 2020.3/2021.
Dim minBox As OrientedBox = combinedBodies.OrientedMinimumRangeBox
' Get length of each side of mininum range box.
Dim dir1 As Double = minBox.DirectionOne.Length
Dim dir2 As Double = minBox.DirectionTwo.Length
Dim dir3 As Double = minBox.DirectionThree.Length
' Convert lengths to document's length units.
Dim uom As UnitsOfMeasure = partDoc.UnitsOfMeasure
dir1 = uom.ConvertUnits(dir1, "cm", uom.LengthUnits)
dir2 = uom.ConvertUnits(dir2, "cm", uom.LengthUnits)
dir3 = uom.ConvertUnits(dir3, "cm", uom.LengthUnits)
' Sort lengths from smallest to largest.
Dim lengths As New List(Of Double) From {dir1, dir2, dir3 }
lengths.Sort
Dim minLength As Integer = lengths(0)
Dim midLength As Integer = lengths(1)
Dim maxLength As Integer = lengths(2)
' Create surface to represent oriented range box...
' Create starting box with dimensions of oriented rangebox.
Dim startBox As Box = transGeom.CreateBox()
Dim boxMaxPoint As Point = transGeom.CreatePoint(minBox.DirectionOne.Length, minBox.DirectionTwo.Length, minBox.DirectionThree.Length)
startBox.Extend(boxMaxPoint)
' Create transformation matrix to move box to correct location/orientation.
Dim transMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix
transMatrix.SetCoordinateSystem(minBox.CornerPoint, minBox.DirectionOne.AsUnitVector.AsVector, minBox.DirectionTwo.AsUnitVector.AsVector, minBox.DirectionThree.AsUnitVector.AsVector)
' Create surface body for the range box.
Dim minBoxSurface As SurfaceBody = ThisApplication.TransientBRep.CreateSolidBlock(startBox)
' Transform range box surface body to the correct location/orientation.
ThisApplication.TransientBRep.Transform(minBoxSurface, transMatrix)
' Display range box on screen.
Dim transac As Transaction = ThisApplication.TransactionManager.StartTransaction(partDoc, "DisplayRangeBox")
Dim cGraphics As ClientGraphics
Try
cGraphics = partDoc.ComponentDefinition.ClientGraphicsCollection.Add("OrientedRangeBox")
Dim surfacesNode As GraphicsNode = cGraphics.AddNode(1)
Dim surfGraphics As SurfaceGraphics = surfacesNode.AddSurfaceGraphics(minBoxSurface)
Dim targetAppearance As Asset
Try
targetAppearance = partDoc.Assets.Item("Clear - Blue")
Catch
Dim sourceAppearance As Asset = ThisApplication.AssetLibraries.Item("314DE259-5443-4621-BFBD-1730C6CC9AE9").AppearanceAssets.Item("InvGen-001-1-2") ' "Clear - Blue"
targetAppearance = sourceAppearance.CopyTo(partDoc)
End Try
surfacesNode.Appearance = targetAppearance
ThisApplication.ActiveView.Update
' Display message with minimum rangebox size.
MessageBox.Show("Oriented Minimum Rangebox Size: " &
minLength.ToString("#.###") & " x " & midLength.ToString("#.###") & " x " & maxLength.ToString("#.###"),
"Oriented Minimum Rangebox", MessageBoxButtons.OK, MessageBoxIcon.Information)
Finally
' Remove range box from screen.
transac.Abort
ThisApplication.ActiveView.Update
End Try
iProperties.Value("Custom", "Material") = "Z" & minLength.ToString("#.###") + 5 & " Y" & midLength.ToString("#.###") + 5 & " X" & maxLength.ToString("#.###") + 5
iProperties.Value("Custom", "Min Material") = minLength.ToString("#.###") & " x " & midLength.ToString("#.###") & " x " & maxLength.ToString("#.###")
iProperties.Value("Custom", "X") = minLength.ToString("#.###")
iProperties.Value("Custom", "Y") = midLength.ToString("#.###")
iProperties.Value("Custom", "Z") = maxLength.ToString("#.###")
and I also try something in vba
Private Sub UserForm_Click()
' Get the active part document.
Dim invPartDoc As PartDocument
Set invPartDoc = ThisApplication.ActiveDocument
' Get the custom property set.
Dim invCustomPropertySet As PropertySet
Set invCustomPropertySet = invPartDoc.PropertySets.Item("Inventor User Defined Properties")
'******
Dim length As Property
Dim width As Property
Dim height As Property
'******
Set length = invCustomPropertySet.Item("X")
Set width = invCustomPropertySet.Item("Y")
Set height = invCustomPropertySet.Item("Z")
'******
'MsgBox length.Value
txtW.Text = length.Value
txtH.Text = width.Value
txtD.Text = height.Value
End Sub
I Am brand new to inventor so I deeply appreciate the help.