REV TABLE PLACE WITH ILOGIC

REV TABLE PLACE WITH ILOGIC

j_cad_files
Explorer Explorer
148 Views
1 Reply
Message 1 of 2

REV TABLE PLACE WITH ILOGIC

j_cad_files
Explorer
Explorer

i have created code to place the revision table to the right of the title block and that work fine.  when i run the code it changes the revsion number to static value.  I have tried other code i have found here and i have the same issue

 

here is my code

Try
' Align the revision table to the right side of the title block and align its Y max with the title block's Y min

' Access the active drawing document
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

' Get the active sheet
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

' Get the title block on the sheet
Dim oTitleBlock As TitleBlock
oTitleBlock = oSheet.TitleBlock

' Validate the title block range
Dim TitleBlockMaxPoint As Point2d
Dim TitleBlockMinPoint As Point2d

TitleBlockMaxPoint = oTitleBlock.RangeBox.MaxPoint
TitleBlockMinPoint = oTitleBlock.RangeBox.MinPoint

Dim XMaxTitle As Double = TitleBlockMaxPoint.X
Dim YMinTitle As Double = TitleBlockMinPoint.Y

' Check if a revision table exists
If oSheet.RevisionTables.Count = 0 Then
' Create a new revision table if none exists
Dim oPosition As Point2d
oPosition = ThisApplication.TransientGeometry.CreatePoint2d(XMaxTitle, YMinTitle) ' Example offset

' Add a new revision table at the specified position
Dim oRevTable As RevisionTable
oRevTable = oSheet.RevisionTables.Add(oPosition)
End If

' Calculate the dimensions of the newly added revision table
If oSheet.RevisionTables.Count > 0 Then
Dim oRevTable As RevisionTable = oSheet.RevisionTables(oSheet.RevisionTables.Count) ' Access the most recently created revision table

Dim RevTableWidth As Double
RevTableWidth = oRevTable.RangeBox.MaxPoint.X - oRevTable.RangeBox.MinPoint.X

Dim RevTableHeight As Double
RevTableHeight = oRevTable.RangeBox.MaxPoint.Y - oRevTable.RangeBox.MinPoint.Y

' Adjust the position to align the revision table's right side with the title block's X max
' and its Y max with the title block's Y min
Dim oPositionFinal As Point2d
oPositionFinal = ThisApplication.TransientGeometry.CreatePoint2d(XMaxTitle - RevTableWidth - 36.5496, YMinTitle + RevTableHeight)

' Set the position of the revision table
oRevTable.Position = oPositionFinal
End If

Catch ex As Exception
' Handle any errors gracefully
MessageBox.Show("An error occurred: " & ex.Message, "iLogic Script")
End Try

 

0 Likes
149 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Maybe try using the RevisionTables.Add2 method, which has a lot more 'input' options available in it, instead of the regular RevisionTables.Add method.  I know revisions can be either document based, or sheet based, but I never use sheet based revisions.  It also wants to default to using numerical revisions, while our company uses alphabetical type.  So, we always have to set several things the way we want them right up front when we first add a revision block to our drawings (Entire Drawing = True, Auto-Index = True, Alpha = True, Start Value = "A").  When doing it manually, we also make sure the checkbox control next to the option named "Update Property on Revision Number Edit" is checked, to make sure the two are 'linked' together, or in sync with each other.  That option is also available by code (RevisionTable.UpdatePropertyToRevisionNumber), but not directly within the 'Add2' method, so we make sure that is also set to True immediately afterwards.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes