This is not a lisp routine way but this is how I match pipe line numbers in PLANT3D
1st: Select an object with the line number that you want the other objects to match.
2nd: Select the other objects now.
3rd: Go to to properties (with objects still selected).
4th: Pick "Line Number Tag" Dropdown
5th: Go all way to the top of the line numbers used list and click on "new..." , alternatively hit "ctrl-home". This will activate the new line number dialog box.
(The latter is a quicker way, using less mouse action).
Last: The info in the "Assign Tag" dialog box will have stored first selected objects line number info.
Pick the "Assign" button or simply just hit enter.
The line number matching is now complete.
All objects picked after the first selected object will now match the first selected object. In other words,
The first object picked piping object will always set the line number for the subsequent selected piping objects.
Using the right click context menu "add to selection" then "Connected Line number" is a useful way to change/match entire line numbers.
Only 3d piping objects can be selected. the properties will not display the line number in the properties box if non PLANT3d entities, like lines or polylines, etc. are also included in the selection.
I know this is is a bit unintuitive, having to hit "new" line number to match existing line numbers of other existing line numbers, but it works.
Hope this is helpful
Robert