Jump to content
SunnyTurtle

Find Rotation Angle of a Block

Recommended Posts

SunnyTurtle

Hi I think this is a simple question for you guys but how do you find the rotation of a block within a drawing that I know the name. I want to create a new USC that is at the same rotation.

 

I have tried Associated List 50 but there does not seem to be a rotation angle in that list is there some way to look into the properties and draw a rotation angle for there

 

Here is a the code I tried

[font=Tahoma][font=Tahoma](setq vfrt (assoc 50 (entsel "a3m_MS_viewframe_01000")))[/font]
[/font]

Share this post


Link to post
Share on other sites
BIGAL

(setq BLOBJ (entget (car (entsel "\nselect block "))))

(setq ang (cdr (assoc 50 BLOBJ)))

Share this post


Link to post
Share on other sites
Tharwat

Another ....

 

(defun c:TesT (/ x s)
 (if
   (setq x (ssget "_x" '((0 . "INSERT") (2 . "a3m_MS_viewframe_01000"))))
    (progn
      (setq s (ssname x 0))
      (alert (strcat (rtos (cdr (assoc 50 (entget s))) 2)
                     " : "
                     "in Radians "
             )
      )
    )
    (alert "There is no Block holds that name in the drawing")
 )
 (princ)
)

Share this post


Link to post
Share on other sites
SunnyTurtle

Thankyou Tharwat and BIGAL for your codes. Tharwat Code is great but it was in need of modification to fit into the lisp I’m working on, which changes to ucs to the same as the object with that name.

BIGAL your code help me understand greatly thankyou

Here a script that does the same thing but it has not way to error check

The problem I have is that i have ucs 1000 in most of my drawings and it is correct but some of them have it strangely missing so i need a way to check if the ucs existed I did that with the (if) statement

 [/font]
[font=Tahoma](ssx) B
a3m_MS_viewframe_01000[/font]
[font=Tahoma]UCS OB
L[/font]
[font=Tahoma]NA
SA
1000
ZE
QSAVE[/font]
[font=Tahoma]

Also Thank you to both of you i have learn a great deal more about lisping but trying to replicate a combination of you lisps and mine and i need to read more about what the ss functions did. This is now clear to me.

I will eventually post the completed lisp but bear with me I’m very slow at this stage

Share this post


Link to post
Share on other sites
Lee Mac

Hi SunnyTurtle

 

Consider that the rotation angle of the block is in Radians, so a conversion may be necessary:

 

(defun c:test ( / e )
 (if
   (and
     (setq e (car (entsel "\nSelect Block: ")))
     (eq "INSERT" (cdr (assoc 0 (entget e))))
   )
   (command "_.ucs" "_z" (angtos (cdr (assoc 50 (entget e)))))
 )
 (princ)
)

However, note that in most cases the 'Object' option may be used to align the UCS:

 

(defun c:uo nil (command "_.ucs" "_OB" pause) (princ))

Share this post


Link to post
Share on other sites
SunnyTurtle

Hi all thanks for the help I have now thought more about this. It would be very easy to solve if I run scrips and lisp together. The problem is that I don't even know if it is possible to run scrips from other files in lisp (if I can understand the lisp that does this)

Here's what I’ve my lisp that would work if I could run scrips within it

Parts in green are I don't know what to do

 
(defun uvf (/ vf usc1000)

 (if;1
;test weather a3m_MS_viewframes_01000 excists
   (setq vf (ssget "_x" '((0 . "INSERT") (2 . "a3m_MS_viewframe_01000"))))

   (if;2
;if true
;then test if ucs 1000 excists
     (setq ucs1000 (= "1000" ([b][color=lime]get ucs name[/color][/b])))
     ([b][color=lime]run a script from search path[/color][/b])          ;if ture run script 1
     ([b][color=lime]run other script from search path[/color][/b])     ;if nil run script 2
     );end if;2

    (alert "No Viewframe 1:1000 in Drawing")     ;if;1 nil give error message
   );end if;1
 );end defun uvf

Thank for your help

Share this post


Link to post
Share on other sites
BIGAL

Rather than run a script run a defun (defun script1 () ...... )

 

(script1) ;if ture run script 1

(script2) ;if nil run script 2

 

Its just part of your lisp program you can have as many defuns as you like in a lisp program.

Share this post


Link to post
Share on other sites
SunnyTurtle

That works fine I guess I wasn't thinking outside the box. But my real issue here is this silly ucs command. I can't find a function that will return the ucs name or something that I can check it with in multiple drawings.

Share this post


Link to post
Share on other sites
Lee Mac
I can't find a function that will return the ucs name

 

(getvar 'ucsname)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...