How to use Fields in XREF title block to read each host drawing's title and sheet number?

How to use Fields in XREF title block to read each host drawing's title and sheet number?

sergio_panadero_bautista
Explorer Explorer
461 Views
3 Replies
Message 1 of 4

How to use Fields in XREF title block to read each host drawing's title and sheet number?

sergio_panadero_bautista
Explorer
Explorer

Hello everyone,

I have recently discovered the magnificent SheetSet feature in AutoCAD and I have run into an issue while creating a sheet set for a project with a large number of layouts that did not previously have one.

 

These layouts use a title block as an XREF, which had the sheet number as a field linked to the Layout Name property. I would like to change it so the field is now linked to the sheet number property within the Sheet Set, but it is not updating correctly across different layouts.

 

Does anyone know if this is possible, and if so, how to set it up?

 

Thanks in advance,

 

Sergio

0 Likes
Accepted solutions (1)
462 Views
3 Replies
Replies (3)
Message 2 of 4

VincentSheehan
Advisor
Advisor

You can create a block to use in each sheet tab where the sheet number and title fields are linked back to Sheet Set Manager.

 

Use Current Sheet Number and Current Sheet Title.

 

Field.png

Vincent Sheehan

Sr. Civil Designer
Poly In 3D Blog

0 Likes
Message 3 of 4

Valentin_CAD
Mentor
Mentor
Accepted solution

@sergio_panadero_bautista ,

 


@sergio_panadero_bautista wrote:

...

 

These layouts use a title block as an XREF ... I would like to change it so the field is now linked to the sheet number property within the Sheet Set, but it is not updating correctly across different layouts.

 


 

You cannot put a sheet-specific field inside the base Xref drawing, it needs to be in each layout.

 

Create an attribute block (use ATTDEF) at the location desired with insertion at 0,0,0; then use a lisp "InsertSheetNum" to place it on every layout.

 

Valentin_CAD_0-1778241519351.png

 

(defun c:InsertSheetNum ( / blkName insPt curLayout)
  (vl-load-com)
  
  ;;; --- CONFIGURATION USER VALUES ---
  (setq blkName "SheetNum") ; Name of your sheet info block
  (setq insPt '(0.0 0.0 0.0))         ; Change to your exact X, Y, Z coordinates in paper space
  ;;; ---------------------------------

  ;; Verify the block exists in the drawing before running
  (if (tblsearch "BLOCK" blkName)
    (progn
      ;; Store the active layout name to return to it at the end
      (setq curLayout (getvar "CTAB"))
      
      ;; Loop through all layouts in the drawing
      (foreach lay (layoutlist)
        (setvar "CTAB" lay) ; Switch to the layout
        
        ;; Verify the block isn't already inserted on this layout to prevent duplicates
        (if (not (ssget "X" (list '(0 . "INSERT") (cons 2 blkName) (cons 410 lay))))
          (progn
            ;; Insert the block silently with zero rotation and scale factors of 1
            (vl-cmdf "_.-insert" blkName "_non" insPt "1" "1" "0")
            (princ (strcat "\nPlaced block on layout: " lay))
          )
          (princ (strcat "\nBlock already exists on layout: " lay))
        )
      )
      
      ;; Restore original layout view and force a visual update
      (setvar "CTAB" curLayout)
      (vl-cmdf "_.regenall")
      (princ "\n--- Automation Completed Successfully! ---")
    )
    (alert (strcat "Error: The block \"" blkName "\" was not found in this drawing.\nPlease define or insert it once first."))
  )
  (princ)
)

  



Select the "Mark as Solution" if my post solves your issue or answers your question.

Seleccione "Marcar como solución" si mi publicación resuelve o responde a su pregunta.


Emilio Valentin

0 Likes
Message 4 of 4

sergio_panadero_bautista
Explorer
Explorer

Thanks a lot for that LISP. I am sure it will do the work!

0 Likes