Author Topic: rectang angle..  (Read 4962 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
rectang angle..
« on: July 27, 2005, 09:19:37 AM »
Hi,

I'm trying to have the orientation angle of a rectang.

any one know the dxf code ? or have another suggestion ?

thanks.
Keep smile...

daron

  • Guest
rectang angle..
« Reply #1 on: July 27, 2005, 10:13:47 AM »
Andrea, a rectangle isn't a defined object, it's a closed polyline. What you might try is getting the angle of the first and second points. You might look into curve parameters to get this or just the first and second group code 10.

Andrea

  • Water Moccasin
  • Posts: 2372
rectang angle..
« Reply #2 on: July 27, 2005, 01:50:47 PM »
ok but how to have the other group 10..?

i have this code..

Quote

  (setq ent_sel1 (entsel "Select text to edit..."))
  (if (= ent_sel1 nil)(exit))  
  (setq ent_sel2 (entget (car ent_sel1)))
  (setq spt_p10 (cdr (assoc 10 ent_sel2)))
Keep smile...

daron

  • Guest
rectang angle..
« Reply #3 on: July 27, 2005, 02:09:03 PM »
Once you have a list of the pline, will this help you? Replace (setq spt_p10 (cdr (assoc 10 ent_sel2))) with code below and see what you get.
Code: [Select]
(foreach item ent_sel2 (if (= (car item) 10) (setq 10list (append
10list (list (cdr item))))))

That should return to you a list of all coordinates in the pline. You should then be able to compare the first two items in the list using angle.

Andrea

  • Water Moccasin
  • Posts: 2372
rectang angle..
« Reply #4 on: July 27, 2005, 03:31:36 PM »
thanks Daron,..that will help me.

in fact...i'm trying to get the angle of the selected line frome a closed polyline.

so with all the endpoints I can't have this because they show me the
first point to the last created point and some time the closed polyline is not a rectangle.

see ?
Keep smile...

daron

  • Guest
rectang angle..
« Reply #5 on: July 27, 2005, 03:33:49 PM »
Eh. You might have more trouble with my method than it might be worth if you want more than the angle of the first two points. To get better results, you'd want to look into vlax-curve parameters. There're lots of them, but they're worth learning.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
rectang angle..
« Reply #6 on: July 27, 2005, 04:43:17 PM »
Extending an example given by Jeff M. to get this.
Code: [Select]
 (setq pline (entsel))
  (setq pick (cadr pline))
  (setq plObj (vlax-ename->vla-object (car pline)))
  (setq pick2 (vlax-curve-getclosestpointto plobj pick))
  (setq param (vlax-curve-getparamatpoint plObj pick2))
  (setq p1 (vlax-curve-getpointatparam plObj (fix param)))
  (setq p2 (vlax-curve-getpointatparam plObj (fix (1+ param))))
  (princ (angle p1 p2))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
rectang angle..
« Reply #7 on: July 27, 2005, 04:53:48 PM »
CAB.....exacly what i need..

but where did you found the "vlax-curve-getclosestpointto"  ?
I have made this...



Quote
   (setq sitem (entsel "\nSélectionnez votre bâtisse : ")
             p1 (osnap (cadr sitem) "_near"))
Code: [Select]


it work also.....but maybe is better your's...

thanks.
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
rectang angle..
« Reply #8 on: July 27, 2005, 05:18:37 PM »
Here is the commented code because most of the vla stuff confuses me.
Code: [Select]
;;  CAB added to code & comments to code by Jeff M. to get the angle of the segment
(defun c:geta ()
  (setq pline (entsel))
  (setq pick (cadr pline))
  ;;  convert ename into a vla object, although this is not needed with the
  ;;  vlax-curve is in keeping with the other methods using vla objects
  (setq plObj (vlax-ename->vla-object (car pline)))
  ;; get a point exactly on the object as entsel may not return the exact point needed
  (setq pick2 (vlax-curve-getclosestpointto plobj pick))
  ;; get parameter, it is vertex # plus percent to next vertex, that ia mu understanding of it
  ;; so a point mid way between vertex 3 & 4 would have a parameter of 3.5
  (setq param (vlax-curve-getparamatpoint plObj pick2))
  ;; get point at vertex, (fix 3.5) = 3
  (setq p1 (vlax-curve-getpointatparam plObj (fix param)))
  ; get point at next vertex, (fix (1+ 3.5)) = 4
  (setq p2 (vlax-curve-getpointatparam plObj (fix (1+ param))))
  ;;  I'm sure you figured this one out
  (princ (angle p1 p2))
  (princ)
)


To get information about commands available look at this picture of the VLIDE editor.
1. highlight the command or in this case part of the command
2. click on the apropos button to bring up the dialog box
3. Highlight the command you want info on
4. Click on the ? help button.

There you have it.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
rectang angle..
« Reply #9 on: July 28, 2005, 07:10:37 AM »
Nice examples CAB. If you want to take fewer steps, place your cursor next to or highlight the function and hit help. You'll get the same results. The apropos is good to give more functions than are sometimes in the help files, though.

Andrea

  • Water Moccasin
  • Posts: 2372
rectang angle..
« Reply #10 on: July 28, 2005, 09:34:08 AM »
CAB..

Your help is very appreciated.

thanks.
Keep smile...

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
rectang angle..
« Reply #11 on: July 28, 2005, 12:04:42 PM »
Quote from: daron
Nice examples CAB. If you want to take fewer steps, place your cursor next to or highlight the function and hit help. You'll get the same results. The apropos is good to give more functions than are sometimes in the help files, though.
Daron, FWIW, back here in R2002 land the only way I can get the help to go to the desired function is through the apropos window. Pressing F1 while the function is highlighted in the editor merely brings up the general help.

daron

  • Guest
rectang angle..
« Reply #12 on: July 28, 2005, 12:08:39 PM »
Thanks. I tend to forget that CAB's still in 2000 land.

Andrea

  • Water Moccasin
  • Posts: 2372
rectang angle..
« Reply #13 on: July 28, 2005, 12:14:12 PM »
Hey,, By the way..

How can I post a screenshot like you did ?

 :?
Keep smile...

daron

  • Guest
rectang angle..
« Reply #14 on: July 28, 2005, 12:50:52 PM »
You see that little pulldown menu at the top right? Open that and select lily pond. When a new window opens up, you'll be prompted for username and password. It's the same as your account as a member of the swamp. Create a new folder called Andrea and in that folder upload your file. Then in the forums, call to it like [img ]path/of/file/here.jpg[/img ].