Get Dimension of sketch to Iproperties

Get Dimension of sketch to Iproperties

haphanthanhtam.work
Enthusiast Enthusiast
1,669 Views
17 Replies
Message 1 of 18

Get Dimension of sketch to Iproperties

haphanthanhtam.work
Enthusiast
Enthusiast

I have a problem to solve
I made in part
First, I show DIMENSION 
Then I pick a value of DIMENSION in Sketch
And save it auto as "L1" in the CUSOM of IPROPERTIES
Capture1.PNG

0 Likes
Accepted solutions (2)
1,670 Views
17 Replies
Replies (17)
Message 2 of 18

A.Acheson
Mentor
Mentor

Hi @haphanthanhtam.work 

You can export a model parameter to iproperty by opening the parameter tab and ticking the export button. Here is an article that shows the manual method and retrieving the parameter by code.

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 18

haphanthanhtam.work
Enthusiast
Enthusiast

Hi @A.Acheson 
thanks for the answer. But for some reason I need to do it in a way of picking each value on Sketch.
you can create a code to do that?

0 Likes
Message 4 of 18

WCrihfield
Mentor
Mentor

Hi @haphanthanhtam.work.  Yes, it is possible to pick a DimensionConstraint within a Sketch, then get the Parameter it represents, then try to expose that Parameter as a custom iProperty.  Here is a simple example iLogic code like that:

oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select a Sketch Dimensional Constraint.")
If oObj Is Nothing OrElse (TypeOf oObj Is DimensionConstraint = False) Then Exit Sub
Dim oDimConst As DimensionConstraint = oObj
Dim oParam As Inventor.Parameter = oDimConst.Parameter
Try
	oParam.ExposedAsProperty = True
Catch
	MsgBox("Error trying to expose the parameter as a custom iProperty!", vbCritical, "Failure")
End Try

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 18

haphanthanhtam.work
Enthusiast
Enthusiast

Hi @WCrihfield Yes
it can output But I need to assign it with a custom name
for ex:

iProperties.Value(oDocFileName, "Custom", "Custom name") = output value

 

0 Likes
Message 6 of 18

Curtis_Waguespack
Consultant
Consultant

Hi @haphanthanhtam.work 


See this example for renaming the exported iProperty, processing the entire sketch.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'example expects a parameter named something like E_Width
'results in an iproperty named something like L_Width

Dim oDoc As PartDocument = ThisDoc.Document
Dim oSketch As PlanarSketch = oDoc.ComponentDefinition.Sketches.Item("Sketch1")
Dim oDimConstraint As DimensionConstraint

For Each oDimConstraint In oSketch.DimensionConstraints
	Dim oParameter As Inventor.Parameter = oDimConstraint.Parameter
	'only export parameters with E_ in the name
	Try : oParameter.ExposedAsProperty = oParameter.Name.Contains("E_")
	Catch : Logger.Info(oParameter.Name & " not exported") : End Try
Next

'rename exported iproperty
For Each oProp As Inventor.Property In oDoc.PropertySets.Item("User Defined Properties")
	If oProp.Name.Contains("E_") Then 
		Try : oProp.DisplayName = oProp.Name.Replace("E_", "L_") : Catch : End Try
	End If
Next

 

EESignature

0 Likes
Message 7 of 18

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @haphanthanhtam.work ,

 

Here's another example using WCrihfield's pick method example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select a Sketch Dimensional Constraint.")
If oObj Is Nothing OrElse (TypeOf oObj Is DimensionConstraint = False) Then Exit Sub
Dim oDimConst As DimensionConstraint = oObj
Dim oParam As Inventor.Parameter = oDimConst.Parameter
Try
	oParam.ExposedAsProperty = False 'set to false, to ensure it is exported again
	oParam.ExposedAsProperty = True
Catch
	MsgBox("Error trying to expose the parameter as a custom iProperty!", vbCritical, "Failure")
End Try

'rename exported iproperty
oProp = ThisDoc.Document.PropertySets.Item("User Defined Properties").Item(oParam.Name) 
ThisDoc.Document.PropertySets.Item("User Defined Properties").Item(oParam.Name).DisplayName  = "L_" & oProp.DisplayName

 

 

EESignature

Message 8 of 18

WCrihfield
Mentor
Mentor
Accepted solution

OK. Here is another similar example that does not try to expose the parameter, and instead just tries to create (or update) a custom iProperty, using the 'Expression' of the Parameter.  The Expression is a String, and usually includes the units specifier, just like you see it in the Parameters dialog.  But it can also contain an equation, which might mess things up here.  But the Value and ModelValue of a Parameter API object is always in 'database units' instead of document units or the parameter's own units, that's why I'm trying to use the Expression instead.  Using the simple Parameter() method could be risky when used within an assembly scenario, and trying to control another document, so I stuck with API methods instead here.

 

oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select a Sketch Dimensional Constraint.")
If oObj Is Nothing OrElse (TypeOf oObj Is DimensionConstraint = False) Then Exit Sub
Dim oDimConst As DimensionConstraint = oObj
Dim oParam As Inventor.Parameter = oDimConst.Parameter
Dim oDoc As Document = Nothing
Try : oDoc = oParam.Parent : Catch : End Try
If oDoc Is Nothing Then Exit Sub
If oDoc.IsModifiable = Fasle Then Exit Sub 'can't create the custom property in it, or change its value
Dim oCProps As PropertySet = oDoc.PropertySets.Item(4)
Dim oCProp As Inventor.Property = Nothing
Dim oCPropName As String = "Custom name"
Try
	oCProp = oCProps.Item(oCPropName)
Catch
	oCProp = oCProps.Add(oParam.Expression, oCPropName)
End Try
If oCProp IsNot Nothing AndAlso oCProp.Value <> oParam.Expression Then
	oCProp.Value = oParam.Expression
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) 👍.

 

Edit:  You could swap out this line:

Dim oCPropName As String = "Custom name"

for this line:

Dim oCPropName As String = InputBox("Enter Custm iProperty Name", "Property Name", oParam.Name)

...to make it more interactive.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 18

WCrihfield
Mentor
Mentor

Another process which might be even better, would be to show you the current name of the parameter, and allow you to rename that first, then continue to expose that parameter as a custom iProperty.  That way, you now know which parameter is controlling it, and do not need to have the parameter and the custom iProperty have different names.  Just a thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 10 of 18

haphanthanhtam.work
Enthusiast
Enthusiast

Thanks so much @Curtis_Waguespack , @WCrihfield @A.Acheson 
It's works
but now there is a problem I keep selecting another value but it's not on Sketch For example dimension on extrusion or other. Is there any way I can pick it up and output that value


screenshot_168995337233333333.png

0 Likes
Message 11 of 18

haphanthanhtam.work
Enthusiast
Enthusiast

Hi@WCrihfield  greate

0 Likes
Message 12 of 18

WCrihfield
Mentor
Mentor

Here is something that might work.  It is probably a FeatureDimension.

 

oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kFeatureDimensionFilter, "Select a feature dimension.")
If oObj Is Nothing OrElse (TypeOf oObj Is FeatureDimension = False) Then Exit Sub
Dim oFDim As FeatureDimension = oObj
Dim oParam As Inventor.Parameter = oFDim.Parameter
Dim sName As String = InputBox("Edit Parameter Name", "Rename Param", oParam.Name)
If sName <> "" Then Try : oParam.Name = sName : Catch : End Try
Try
	oParam.ExposedAsProperty = True
Catch
	MsgBox("Error trying to expose the parameter as a custom iProperty!", vbCritical, "Failure")
End Try

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 13 of 18

WCrihfield
Mentor
Mentor

Actually, here is a version of that last code where it will allow you to pick either type of object, then check which type you selected, then get the parameter from it.  If it is neither of those two types, it will exit the rule.  Then it lets you rename the parameter associated with what you picked.  Then it tries to expose that as a custom iProperty.

oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select a feature or sketch dimension.")
If oObj Is Nothing Then Exit Sub
Dim oParam As Inventor.Parameter = Nothing
If TypeOf oObj Is FeatureDimension Then
	Dim oFDim As FeatureDimension = oObj
	oParam = oFDim.Parameter
ElseIf TypeOf oObj Is DimensionConstraint Then
	Dim oDimConst As DimensionConstraint = oObj
	oParam = oDimConst.Parameter
Else
	Exit Sub
End If
Dim sName As String = InputBox("Edit Parameter Name", "Rename Param", oParam.Name)
If sName <> "" Then Try : oParam.Name = sName : Catch : End Try
Try
	oParam.ExposedAsProperty = True
Catch
	MsgBox("Error trying to expose the parameter as a custom iProperty!", vbCritical, "Failure")
End Try

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 14 of 18

haphanthanhtam.work
Enthusiast
Enthusiast

Hi @WCrihfield
Thanks for the help
Can i ask you 1 question. It will solve a string of my problems
I have a code used to get the minimum bounding box dimensions
Instead of showing 3 sizes I want it to show notifications
Ex:  20 x 37,895 x 50
I want it to announce that:  This value is 20 you will assign "Custom name"(I will input custom name value)
I want it to announce that:  This value is 37,895 you will assign "Custom name"(I will input custom name value)
I want it to announce that:  This value is 50 you will assign "Custom name"(I will input custom name value)


I think you can help me, you can help me

This 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 Double = lengths(0)
Dim midLength As Double = lengths(1)
Dim maxLength As Double = 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


screenshot_1689955038cccccc.png

 




 

0 Likes
Message 15 of 18

WCrihfield
Mentor
Mentor

That is a pretty long and complex rule.  Since all of that geometry it creates is just transient (math only, not real), it will not have any real dimension objects or parameters that will stay after the transaction is aborted.  What would we be assigning a named to?  Do you simply want to customize the final message with a custom specified name for what each size represents, or do you want this rule to create 3 custom iProperties (one for each directional size), and write these values to those iProperties?  Or would you prefer to create 3 user parameters?  Keep in mind that if the code creates iProperties or parameters, those values will just be static, and will not actually be linked to anything real, so they will not stay accurate if something changes in the model afterwards.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 16 of 18

haphanthanhtam.work
Enthusiast
Enthusiast

i want this rule to create 3 custom iProperties (one for each directional size), and write these values to those iProperties. I know it won't change when the model changes

cccccssssssssss.png
 33333333.png

0 Likes
Message 17 of 18

WCrihfield
Mentor
Mentor

OK.  I added this section of code to your rule, just after the 3 values have been converted and sorted, but just before it starts the 'transaction', so that they will not be removed when the transaction is aborted.

'write values to custom iProperties with prompts for names
Dim sName1, sName2, sName3 As String

sName1 = InputBox("This value is " & minLength, "Assign Property Name", "")
If sName1 <> "" Then iProperties.Value("Custom", sName1) = minLength

sName2 = InputBox("This value is " & midLength, "Assign Property Name", "")
If sName2 <> "" Then iProperties.Value("Custom", sName2) = midLength

sName3 = InputBox("This value is " & maxLength, "Assign Property Name", "")
If sName3 <> "" Then iProperties.Value("Custom", sName3) = maxLength

...below is the whole thing, after that has been added in.  I hope this works the way you want it to.

' 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 Double = lengths(0)
Dim midLength As Double = lengths(1)
Dim maxLength As Double = lengths(2)

'write values to custom iProperties with prompts for names
Dim sName1, sName2, sName3 As String

sName1 = InputBox("This value is " & minLength, "Assign Property Name", "")
If sName1 <> "" Then iProperties.Value("Custom", sName1) = minLength

sName2 = InputBox("This value is " & midLength, "Assign Property Name", "")
If sName2 <> "" Then iProperties.Value("Custom", sName2) = midLength

sName3 = InputBox("This value is " & maxLength, "Assign Property Name", "")
If sName3 <> "" Then iProperties.Value("Custom", sName3) = maxLength

' 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

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 18 of 18

haphanthanhtam.work
Enthusiast
Enthusiast

Hi @WCrihfield
I try it in a part

' 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 Double = lengths(0)
Dim midLength As Double = lengths(1)
Dim maxLength As Double = 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



Dim oCPropName As String = InputBox("Enter Custm iProperty Name", "Property Name", midLength)
Try
	oCProp = oCProps.Item(oCPropName)
Catch
	oCProp = oCProps.Add(oParam.Expression, oCPropName)
End Try
If oCProp IsNot Nothing AndAlso oCProp.Value <> oParam.Expression Then
	oCProp.Value = oParam.Expression
End If










	' Display message with minimum rangebox size.
	
Finally
	' Remove range box from screen.
	transac.Abort
	ThisApplication.ActiveView.Update
End Try

 

it's going wrong from here You can export its value to iproperties like your code worked.

Try
	oCProp = oCProps.Item(oCPropName)
Catch
	oCProp = oCProps.Add(oParam.Expression, oCPropName)
End Try
If oCProp IsNot Nothing AndAlso oCProp.Value <> oParam.Expression Then
	oCProp.Value = oParam.Expression
End If


 

0 Likes