See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: TORIENT & Other LSP

  1. #1
    Member
    Join Date
    2009-01
    Posts
    2
    Login to Give a bone
    0

    Default TORIENT & Other LSP

    I have a block containing DTEXT and a block attribute (its for heights on beams and reads "BH 2.01"). The "BH" is the DTEXT, Middle Right justified and the "2.01" is the attribute Middle Left justified). The block insertion point is the centre of whole text string.

    I have an align lsp which you click the block and click a line and the block rotates to match the angle of the line. Whilst the block rotates, this only rotates the DTEXT in the block and not the attribute. If I use TORIENT from Express Tools, the block rotates again but rotates the attribute and not the DTEXT. What I'm looking for is a routine / command / workflow that rotates the whole block (and everything in it) to match a line or polyline around the block insertion point?

    AutoCAD 2022
    Win 10 Pro

    Many thanks

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,962
    Login to Give a bone
    1

    Default Re: TORIENT & Other LSP

    Hi Andy, welcome to AUGI.

    Good description, but you might also want to post a sample of your block.
    C:> ED WORKING....

  3. #3
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    947
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    Its simple enough, just add a few codes to your align lisp to rotate the attribute when rotating the block itself.

  4. #4
    Member
    Join Date
    2009-01
    Posts
    2
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    Thanks for the responses - its a lisp I've inherited and I don't know lisp as such - Can anyone point me towards the correct lisp command / routine to look into please?

  5. #5
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    947
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    Just add the following after selecting the block entity along with the angle value.
    Code:
    ;; Where :
    ;; blk = is Block entity.
    ;; ang = is the angle value.
    
    (foreach att (vlax-invoke (vlax-ename->vla-object blk) 'GetAttributes)
      (vla-put-rotation att ang)
      )

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,793
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    Quote Originally Posted by Tharwat View Post
    ;; ang = is the angle value.
    The supplied ang value should be in radians, correct?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    947
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    Quote Originally Posted by Opie View Post
    The supplied ang value should be in radians, correct?
    Yeah correct.

  8. #8
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    508
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    You may need these as well.

    Code:
    ;The dtr function converts degrees to radians
    ;The rtd function converts radians to degrees
    (defun dtr (a)
    (* pi (/ a 180.0))
    )
    ;
    (defun rtd (a)
    (/ (* a 180.0) pi)
    )

  9. #9
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,568
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    Quote Originally Posted by andy.204833 View Post
    Thanks for the responses - its a lisp I've inherited and I don't know lisp as such - Can anyone point me towards the correct lisp command / routine to look into please?
    Many of us probably have already written code solutions that do what you want but without an attachment or link to a drawing to test it on we're reluctant to post them.

  10. #10
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Chelan WA
    Posts
    1,060
    Login to Give a bone
    0

    Default Re: TORIENT & Other LSP

    Try this

    Code:
    ;___________________________________________________________________________________________________________|
    ;
    ; Written By: Peter Jamtgaard C.E., P.E., S.E. copyright 2022 All Rights Reserved
    ;___________________________________________________________________________________________________________|
    
    ; Abstract: This function will rotate a block with attributes to match the rotation of a selected line
    
    ;___________________________________________________________________________________________________________|
    ;
    ; Comand line function list
    ;___________________________________________________________________________________________________________|
    
    ;* C:BAR 
    ;* Command Line Function to rotate a block to match a line
    
    ;* C:BlockAndAttributeRotate
    ;* Command Line Function to rotate a block to match a line
    
    ;___________________________________________________________________________________________________________|
    ;
    ; General Function Header List
    ;___________________________________________________________________________________________________________|
    
    ;* (AttributeRotate objBlock sngRadians)
    ;* Function to rotate attributes in a block to radians angle
    
    ;* (BlockAndAttributeRotate objLine objBlock)
    ;* Function to rotate a block and attributes
    
    ;* (EntitySelectOne strPrompt lstFilter )
    ;* Function to select one object with a filter
    
    ;* (ErrorTrap symFunction)
    ;* Function to trap error
    
    ;$ EndHeader
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Command Line Function to rotate a block to match a line
    ;___________________________________________________________________________________________________________|
    
    (defun C:BAR ()(C:BlockAndAttributeRotate))
    
    (defun C:BlockAndAttributeRotate (/ objBlock objLine)
     (if (and (setq objLine      (EntitySelectOne "\nSelect Line: " (list (cons 0 "line"))))          
              (setq objBlock     (EntitySelectOne "\nSelect A Block With Attributes: " 
                                                  (list (cons 0 "insert")(cons 66 1))
                                 )
              )          
         )
      (BlockAndAttributeRotate objLine objBlock)
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Function to rotate a block and attributes
    ;___________________________________________________________________________________________________________|
    
    (defun BlockAndAttributeRotate (objLine objBlock / sngRadians)
     (if (and (setq sngRadians   (vla-get-angle objLine))          
              (errortrap         '(vla-put-rotation objBlock sngRadians))     
         )
      (AttributeRotate objBlock sngRadians)
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Function to rotate attributes in a block to radians angle
    ;___________________________________________________________________________________________________________|
    
    (defun AttributeRotate (objBlock sngRadians / lstAttributeObjects objAttribute)
     (if (and (vla-get-hasattributes objBlock)
              (setq lstAttributeObjects (vlax-invoke objBlock "getattributes"))
         )
      (foreach objAttribute lstAttributeObjects
       (errortrap '(vla-put-rotation objAttribute sngRadians))
      )
     )
    )
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Function to select one object with a filter
    ;___________________________________________________________________________________________________________|
    
    (defun EntitySelectOne (strPrompt lstFilter / entSelection objSelection ssSelections)
     (while (not (if (and (princ strPrompt)
                          (setq ssSelections (ssget ":S:E" lstFilter))
                          (setq entSelection (ssname ssSelections 0))
                     )
                  (setq objSelection (vlax-ename->vla-object entSelection))
                 )
            )
      (princ "\nInvalid Selection Please Select Again: ")
     )
     objSelection
    )
    
    ;___________________________________________________________________________________________________________|
    ; 
    ; Function to trap error
    ;___________________________________________________________________________________________________________|
    
    (defun ErrorTrap (symFunction / objError result)
     (if (vl-catch-all-error-p
          (setq objError (vl-catch-all-apply
                         '(lambda (X)(set X (eval symFunction)))
                          (list 'result))))
      nil
      (if result result 'T)
     )
    )
    
    (princ "!")
    (vl-load-com)
    Attached Files Attached Files
    AutomateCAD

Similar Threads

  1. 2015: Structural Framing (other) - can you change (other) to some other Category?
    By troypiggo in forum Revit Structure - General
    Replies: 5
    Last Post: 2014-05-15, 11:11 PM
  2. Using Torient
    By Borgster in forum AutoLISP
    Replies: 3
    Last Post: 2012-06-18, 01:00 PM
  3. torient command in lisp
    By mbergink in forum AutoLISP
    Replies: 3
    Last Post: 2008-12-24, 04:15 AM
  4. Express Tools command Torient - Invalid point.
    By Richard McDonald in forum AutoCAD General
    Replies: 8
    Last Post: 2007-05-30, 09:20 AM

Posting Permissions

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