Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi All, i'm after a little macro

Status
Not open for further replies.

Alan Lowbands

Aerospace
May 17, 2017
274
Hi All,

i'm after a little macro I can run on certain dimensions to save me having to alter the tolerance and type each time.
Could anyone give me an example of what needs to go in the line below please.

I can't find anything that explaines what each value does.
Any example would be really appreciated


DimDimValue.SetTolerances(iTolType, itolName, iUpTol, iLowTol, idUpTol, idLowTol, DisplayMode)

many thanks
Alan
 
Replies continue below

Recommended for you

Hi,

This is something I had from a while back but you need to run it twice to get the +- 0.1 to be added.
Anyone know why ?

thanks..

Sub CATMain()

Dim documents1
Set documents1 = CATIA.Documents

Set Document = CATIA.ActiveDocument

Dim selection1
Set selection1 = Document.Selection

Set Info = selection1.Item(1)

Dim Dimension1
Set Dimension1 = Info.Value

Dim DimTolValue
Set DimTolValue = Dimension1

Dim oTolType
Dim oDisplayMode
Dim oTolName
Dim oUpTolS
Dim oLowTolS
Dim oUpTolD
Dim oLowTolD
DimTolValue.GetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode
oTolName = "TOL_NUM2"
oUpTolD = 0.1
oLowTolD = -0.1
DimTolValue.SetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode

Dim DimDimValue
Set DimDimValue = Dimension1.GetValue
DimDimValue.SetFormatName 1, "ANS.DIMM"
DimDimValue.SetFormatPrecision 1, "0.100" 'precision

End Sub
 
Alan,
add the two lines.

Sub CATMain()

Dim documents1
Set documents1 = CATIA.Documents

Set Document = CATIA.ActiveDocument

Dim selection1
Set selection1 = Document.Selection

Set Info = selection1.Item(1)

Dim Dimension1
Set Dimension1 = Info.Value

Dim DimTolValue
Set DimTolValue = Dimension1

Dim oTolType
Dim oDisplayMode
Dim oTolName
Dim oUpTolS
Dim oLowTolS
Dim oUpTolD
Dim oLowTolD
DimTolValue.GetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode
oTolName = "TOL_NUM2"


'add these two here
DimTolValue.SetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode
DimTolValue.GetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode



oUpTolD = 0.1
oLowTolD = -0.1
DimTolValue.SetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode

Dim DimDimValue
Set DimDimValue = Dimension1.GetValue
DimDimValue.SetFormatName 1, "ANS.DIMM"
DimDimValue.SetFormatPrecision 1, "0.100" 'precision

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor