Adapt Lisp that gives layout and total layout number

Hello everyone,

I am new at bricscad and i am migrating from Autocad.
Everything is working good but some lisps do not work and i need them.
As i am not proeficient in lisp programming i need tthe comunity help.

I have an amazing lisp from the guru Lee Mac that works but dont give the proper results.
It substitute an text on layouts with layout number (position) and total number of layouts.
And if i move a layout all the references change.
I am not sure but i am guessing the the problem is that the object attribute is not working.

Can you look at the original lisp and try and see what need to be change to work with Bricscad lisps?

I have attatched the file so you can see it.

Thank you in advanced

(if anything isnt properly explanied please tell me because english is not my primarly language)


Comments

  • Can anyone please help?

    I have other lisps that give errors but this one does not ...

    thx
  • I'd help if I could, but this code is more advanced than what I write. Lee posts in the LISP forum at www.theswamp.org, and there are a number of others that might also be able to help.
  • ALANH
    edited July 2022
    You can contact Lee at his web site lee-mac.com

    Also post at Cadtutor.

    I get errors will have a look further. Lee is very helpful.
  • Thx you @ALANH and @martin@enco.us

    i allready emailed him but i dont know if he works with bricscad lisps and thats why i hasked here.

    The lisp works great on cad but here it doest.

    Thx
  • This isn't an issue with Lee Mac's LISP. The problem is with BricsCAD. Issue is two-fold:
    • BricsCAD can't retrieve the object properties (IAcadLayout.TabOrder, & IAcadLayouts.Count) assigned in the FIELD.
    • The total number of sheets also uses a nested formula. BricsCAD doesn't correctly create these when pushed/pasted into the text entity.
    To get these issues resolved, you would need to raise a support request with Bricsys.

    It is possibly to create a workaround using LISP that will do something similar by finding the necessary values, and pushing them to a custom doc property (DWGPROPS) for retrieval by the FIELD.

    The attached SheetNumbers.lsp will create custom document props of the position of each of the layouts on the drawing, plus the total number of layouts.

    These properties have the following naming convention:
    *LAYOUT-HANDLE-NUMBER* where HANDLE is the unique handle of the layout.

    Having created them you can retrieve their values via a FIELD


    To automatically update the fields, you need to set the SheetNumbers.lsp to load with each drawing. You can do this by adding a call to your on_doc_load.lsp.

    I've also modified Lee Mac's LISP to use this method instead, see attached.


    Regards,
    Jason Bourhill
    BricsCAD V22 Ultimate
    CAD Concepts
  • Hello @Jason Bourhill ,

    thank you very much for that insight and for having some time to spend with me.
    Maybe this will help others.

    As a side note, this started because some of us had the LT version and others the full version of cad.
    So we had to find a way to automatic update the sheet number / total sheet number without lisp.

    I suppose we will allways find a edge that is yet unreacheable.
    This things also happened to me when i worked with Vectorworks.

    "BricsCAD can't retrieve the object properties (IAcadLayout.TabOrder, & IAcadLayouts.Count) assigned in the FIELD."
    Does this mean that bricscad dont have a function to retrieve it or can't assign them to a FIELD? Sorry i perhaps misundertand your answer.

    "To get these issues resolved, you would need to raise a support request with Bricsys."
    Ok, keep on pushing things forward. As soon as i get more familiar with it i will.

    "It is possibly to create a workaround using LISP that will do something similar by finding the necessary values, and pushing them to a custom doc property (DWGPROPS) for retrieval by the FIELD."

    I ran your code and found that to update the number field (if i have to move layouts around) i can do it 2 ways:
    1) close and reopen the drawing;
    2) create a menu command that executes your function "(SheetNumbers)" + regen.

    This is very cool indeed.

    Is there a better way to do this? Does Bricscad have a function that we can implement on our title blocks so that it find the number of the layout / total number?
    Or something similar to sheets set?

    Thank you very much again
  • g3n3tics said:


    "BricsCAD can't retrieve the object properties (IAcadLayout.TabOrder, & IAcadLayouts.Count) assigned in the FIELD."
    Does this mean that bricscad dont have a function to retrieve it or can't assign them to a FIELD? Sorry i perhaps misundertand your answer.

    FIELDs allow you to create a text entity that is linked to the properties of an object. For example: from the FIELD dialog, if you select a LINE object, then it will display a list of available properties.

    As an aside, you will notice that the listed properties are essentially the same as what you would see on the Properties Panel.

    Generally speaking in the case of objects, a BricsCAD FIELD can access the properties of graphically selectable objects. In the case of Lee Mac's application , he is accessing the properties of the Layouts & Layout object by use of LISP code. It's these non-graphical objects that a BricsCAD FIELD can't currently access.

    These properties are available by other methods, such as LISP. E.g. the following will list the properties of the current layout.
    (vlax-dump-object (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'CTAB)) T)
    You will note that there is a property called taborder that gives the layouts position.

    The following code will list the properties of the layout collection
    (vlax-dump-object (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) T)
    You will note that there is a property called count that gives the total number of layouts including model space.
    g3n3tics said:


    I ran your code and found that to update the number field (if i have to move layouts around) i can do it 2 ways:
    1) close and reopen the drawing;
    2) create a menu command that executes your function "(SheetNumbers)" + regen.

    The LISP included a command reactor that would automatically run "(SheetNumbers)" when you used a printing command. I've updated the reactor to include the REGEN comand. See attached.
    g3n3tics said:


    Is there a better way to do this?

    I would investigate using Sheetsets. These include sheet number and a total number of sheets, which can access via a FIELD on your drawings.

    Regards,
    Jason Bourhill
    BricsCAD V22 Ultimate
    CAD Concepts
  • As Jason hinted I have always just done a update layout count, num, but not as fields. The count if from the layouts property and the layout number is done by comparing current layout with Taborder.

    I can put something together but it uses a title block with attributes. So updates the correct attribute, so would need more info, title block name attribute tag names.


  • @Jason Bourhill

    Thank you again, the regen option for update the fields works great.

    In fact the fields aren't essential. If a lisp does the trick we can stay on it.
    So, how can we use your two lisp commands to retrieve taborder and count?
    Does it needs to also be on the drawings properties?

    @ALANH
    We use a title block that gets info from filename and from custom drawings properties.
    I have attatched a sample so that you both can see it.

    Thank you so much for your pacience with me

  • As I said this would be an attribute and replace with a value like "12 / 25" just going through all layouts and updating.
  • g3n3tics said:

    @Jason Bourhill
    In fact the fields aren't essential. If a lisp does the trick we can stay on it.
    So, how can we use your two lisp commands to retrieve taborder and count?

    If you want just the taborder, then you can use
    (vla-get-taborder (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (getvar 'CTAB)))

    This gives the taborder for the current tab. If you want the number for a specific sheet, then you would swap out (getvar 'CTAB) with the sheet name.

    If you want just the layout count then you can use
    (vla-get-count (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))))
    This count will include the model space tab, so to get the paper space layout count you would use
    (1- (vla-get-count (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))))
    or
    (length (layoutlist))
    g3n3tics said:

    @Jason Bourhill
    Does it needs to also be on the drawings properties?

    No, you don't need to use drawing properties. As Alan has mentioned, you could push the values straight into your Titleblocks.

    The advantage to pushing to drawing properties, is that it gives you more flexibility in how you use the information without the need of creating any further code. As an example, if you look at the Sheet.dwg that I included, you will see that I've manually added FIELDs to my titleblock referring to the same drawing properties.


    Regards,
    Jason Bourhill
    BricsCAD V22 Ultimate
    CAD Concepts
  • @Jason Bourhill

    Sorry to nagg you but i tryed to implement your code in a formula on bricscad but i could not.
    What am i missing?

    Can you please share your drawing (it wasnt included in your post) ?

    Thank you
  • g3n3tics said:

    @Jason Bourhill
    Sorry to nagg you but i tryed to implement your code in a formula on bricscad but i could not.
    What am i missing?

    This is LISP code. If you copy and paste into the commandline, then BricsCAD will evaluate.
    g3n3tics said:

    @Jason Bourhill
    Can you please share your drawing (it wasnt included in your post) ?
    Thank you

    See the sheets.zip file that was included in my first post.


    Regards,
    Jason Bourhill
    BricsCAD V22 Ultimate
    CAD Concepts
  • g3n3tics
    edited August 2022
    Hello again,

    "This is LISP code. If you copy and paste into the commandline, then BricsCAD will evaluate."

    That part i knew ;)

    I wonder if it was possible to insert it on a field so that it updates automaticly.
    Or does it have to place it on a global variables and retriving them on fields?

    Thx you
  • Hello again,

    Thank you very much @Jason Bourhill and @ALANH .

    your answers where very useful.

    Best regards