+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    Civil 3D 2017
    Join Date
    Jan 2018
    Posts
    6

    Default Edit to existing LISP routine

    Registered forum members do not see this ad.

    Hi all,

    Really need a hand here.

    I have slightly edited the program from Lee Mac "areas2field" and added the line

    (setq format "%lu2%pr2%ps[, ha]%ct8[0.0001]") ;; Field Formatting

    This allows me to select a boundary and return the reading as an area in hectares, example output is "12.35 ha"

    I would like to modify output to also convert to acres
    for it to read like this "5.00 ac / 12.35 ha"

    Appreciated your help in advance.

  2. #2
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    Civil 3D 2017
    Join Date
    Jan 2018
    Posts
    6

    Default

    BTW, I attempted something like this (setq format "%lu2%pr2%ps[, ac]%ct8[0.0002471044] / %lu2%pr2%ps[, ha]%ct8[0.0001]") ;; Field Formatting

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,461

    Default

    Are you using Version 1.3 of the program from here?
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  4. #4
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    Civil 3D 2017
    Join Date
    Jan 2018
    Posts
    6

    Default

    Quote Originally Posted by Lee Mac View Post
    Are you using Version 1.3 of the program from here?
    Hi Lee, yes that's correct.

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,461

    Default

    Your code snippet made me think otherwise, as the current code does not have a 'format' variable.

    Nevertheless, as a quick fix, make the following changes:

    Change Line 31 from:
    Code:
        (setq fmt "%lu6%qf1") ;; Field Formatting
    to:
    Code:
        (setq fm1 "%lu6%qf1" ;; Field Formatting
              fm2 "%lu6%qf1"
        )
    Change Lines 60-66 (inclusive) from:
    Code:
                    (setq str
                        (strcat
                            "%<\\AcObjProp Object(%<\\_ObjId "
                            (LM:ObjectID (vlax-ename->vla-object (ssname sel 0)))
                            ">%).Area \\f \"" fmt "\">%"
                        )
                    )
    to:
    Code:
                    (setq str
                        (strcat
                            "%<\\AcObjProp Object(%<\\_ObjId "
                            (LM:ObjectID (vlax-ename->vla-object (ssname sel 0)))
                            ">%).Area \\f \"" fm1 "\">%"
                            " / "
                            "%<\\AcObjProp Object(%<\\_ObjId "
                            (LM:ObjectID (vlax-ename->vla-object (ssname sel 0)))
                            ">%).Area \\f \"" fm2 "\">%"
                        )
                    )
    Change Lines 78-84 (inclusive) from:
    Code:
                        (setq str
                            (strcat
                                "%<\\AcExpr "
                                (apply 'strcat (reverse (cdr (reverse lst))))
                                " \\f \"" fmt "\">%"
                            )
                        )
    to:
    Code:
                        (setq str
                            (strcat
                                "%<\\AcExpr "
                                (apply 'strcat (reverse (cdr (reverse lst))))
                                " \\f \"" fm1 "\">%"
                                " / "
                                "%<\\AcExpr "
                                (apply 'strcat (reverse (cdr (reverse lst))))
                                " \\f \"" fm2 "\">%"
                            )
                        )
    And populate the variables fm1 and fm2 with the formatting for the fields on each side of the forward slash.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  6. #6
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    Civil 3D 2017
    Join Date
    Jan 2018
    Posts
    6

    Default

    Hi Lee,

    Thanks very much for that. I have made those adjustments however it's not working for me.

    I am not getting an error on load, it seems to work but is not output any text at all. It will realise I have selected an object then ask me where to place it, but shows up blank.

    I have uploaded a copy here, https://pastebin.com/fVv7phXS

    Could you please spot what I have done wrong?
    Appreciate your help!

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,461

    Default

    I think you misunderstood my instruction: "And populate the variables fm1 and fm2 with the formatting for the fields on each side of the forward slash."

    You should only change the values of fm1 & fm2, not substitute values where I have used these variables.

    i.e. When I instructed: "And populate the variables fm1 and fm2 with the formatting for the fields on each side of the forward slash.", I meant that you should set this part:

    Code:
        (setq fm1 "%lu6%qf1" ;; Field Formatting
              fm2 "%lu6%qf1"
        )
    to your formatting of choice, e.g.:

    Code:
        (setq fm1 "%lu2%pr2%ps[, ac]%ct8[0.0002471044]" ;; Field Formatting
              fm2 "%lu2%pr2%ps[, ha]%ct8[0.0001]"
        )
    Sorry, I thought this was clear.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    Civil 3D 2017
    Join Date
    Jan 2018
    Posts
    6

    Default

    Surprise surprise I knew I would much it up.

    But it's very clear, changed it and works perfectly!
    Thank you so much.

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,461

    Default

    Excellent - you're welcome.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  10. #10
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    Civil 3D 2017
    Join Date
    Jan 2018
    Posts
    6

    Default

    Registered forum members do not see this ad.

    Sorry one last question how can output this text as Arial Narrow with text height 2.5?
    Can it be done?

Similar Threads

  1. Lisp routine to measure line and add length to existing text
    By emwhite in forum AutoLISP, Visual LISP & DCL
    Replies: 26
    Last Post: 23rd Nov 2016, 11:31 am
  2. Need help on an existing offset lisp routine
    By vernonlee in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 17th Feb 2015, 01:31 am
  3. Help with existing LISP routine
    By KHoughton in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 18th Feb 2013, 11:02 pm
  4. Text edit lisp routine
    By jondoeiowa in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 5th Aug 2011, 08:23 am
  5. dim text edit lisp routine??
    By BLOACH85 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 8th May 2009, 09:11 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts