Author Topic: Rotated rectangle with osnaps?  (Read 4486 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
Rotated rectangle with osnaps?
« on: November 05, 2007, 10:50:17 AM »
Using Stig's rotated rectangle code here, it allows you to draw a rotated rectangle based on selected points and direction.  First you select the length of your rectangle and then the distance.  The second distance doesn't accept any osnap.  Can someone help me figure out how to get it to accept osnaps?
« Last Edit: November 07, 2007, 08:41:33 AM by Daron »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Rotated rectangle with osnaps?
« Reply #1 on: November 05, 2007, 11:02:43 AM »
Look at the code here to see how I did it (with some code posted here already).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

whdjr

  • Guest
Re: Rotated rectangle with osnaps?
« Reply #2 on: November 05, 2007, 01:31:19 PM »
Tim,

I run your tool and after I pick the first point I move my mouse to pick my angle and it gives this
Error-> no function definition: STRPARSE

Do you have that function?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Rotated rectangle with osnaps?
« Reply #3 on: November 05, 2007, 01:44:33 PM »
Tim,

I run your tool and after I pick the first point I move my mouse to pick my angle and it gives this
Error-> no function definition: STRPARSE

Do you have that function?
Sorry.  I thought I added it there.
Code: [Select]
(defun StrParse (String Seperator / Pos1 Pos2 NewStrList)
;|
  Seperator a string (making a list of stings) at a given
  string value
  ie: (StrParse "1,1,0" ",")
  returns: ("1" "1" "0")
  Written when I couldn't find it on the web
  By: Tim Willey 11/15/2004
|;

(setq Pos2 1)
(while (setq Pos1 (vl-string-search Seperator String Pos1))
 (if (= Pos2 1)
  (setq NewStrList (cons (substr String Pos2 Pos1) NewStrList))
  (setq NewStrList (cons (substr String Pos2 (- (1+ Pos1) Pos2)) NewStrList))
 )
 (setq Pos2 (1+ (+ (strlen Seperator) Pos1)))
 (setq Pos1 (+ Pos1 (strlen Seperator)))
)
(reverse (setq NewStrList (cons (substr String Pos2) NewStrList)))
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

whdjr

  • Guest
Re: Rotated rectangle with osnaps?
« Reply #4 on: November 05, 2007, 03:14:59 PM »
No offense Tim. but I still can't get it to work.  Any chance you could look at my question?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Rotated rectangle with osnaps?
« Reply #5 on: November 05, 2007, 03:24:25 PM »
No offense Tim. but I still can't get it to work.  Any chance you could look at my question?
The problem is it's not an easy question to answer.  The problem is he uses 'grread' and that doesn't work with osnaps, so my code does because of code written by fools and CAB.  See if this thread helps you better understand what is needed.  This what I read, and took from, when writing my code.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Rotated rectangle with osnaps?
« Reply #6 on: November 05, 2007, 03:26:30 PM »
If you are not concerned about a visual Osnap could you not use the Osnap function to
get it to snap to an object?
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.

whdjr

  • Guest
Re: Rotated rectangle with osnaps?
« Reply #7 on: November 05, 2007, 03:50:52 PM »
If you are not concerned about a visual Osnap could you not use the Osnap function to
get it to snap to an object?

I'm not sure what your asking.  I use running osnaps.  I typed in an osnap name.  I used shift-right-click.  Nothing I tried worked.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Rotated rectangle with osnaps?
« Reply #8 on: November 05, 2007, 04:42:51 PM »
If you are not concerned about a visual Osnap could you not use the Osnap function to
get it to snap to an object?

I'm not sure what your asking.  I use running osnaps.  I typed in an osnap name.  I used shift-right-click.  Nothing I tried worked.
What he means is could just have the point that is selected set to a point that is selected by an osnap if one exists.  Or do you have to see which osnap it will snap to?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

whdjr

  • Guest
Re: Rotated rectangle with osnaps?
« Reply #9 on: November 06, 2007, 02:52:44 PM »
If you are not concerned about a visual Osnap could you not use the Osnap function to
get it to snap to an object?

I'm not sure what your asking.  I use running osnaps.  I typed in an osnap name.  I used shift-right-click.  Nothing I tried worked.
What he means is could just have the point that is selected set to a point that is selected by an osnap if one exists.  Or do you have to see which osnap it will snap to?
I still don't understand what you guys are asking me.  No I don't have to see the symbol that pops up when a running osnap is selected, but I would like to select a point using an osnap.

SomeCallMeDave

  • Guest
Re: Rotated rectangle with osnaps?
« Reply #10 on: November 06, 2007, 03:03:49 PM »
You might want to look at this thread

http://www.theswamp.org/index.php?topic=9133.0

Alexander has posted some ARX files that simulate grread functionality and support osnaps.


T.Willey

  • Needs a day job
  • Posts: 5251
Re: Rotated rectangle with osnaps?
« Reply #11 on: November 06, 2007, 03:29:34 PM »
In this section of code
Code: [Select]
         (cond ((vl-consp final)
                (drawRect pt1 pt2 ang (* (distance pt1 final) (sin (- (angle pt1 final) ang))))
               )
               ((numberp final)
                (drawRect pt1 pt2 ang final)
               )
         )
You will see if the point (final) can snap to an objects snap points.  So you can test it like
Code: [Select]
(if (osnap final "end")
  (setq final (osnap final "end"))
)
This is where Alan's function comes in handy because you can pass the string that is returned to the osnap function.
So I would use it like
Code: [Select]
  (defun get_osmode (/ cur_mode mode$)
    (setq mode$ "")
    (if (< 0 (setq cur_mode (getvar "osmode")) 16383)
      (mapcar
        '(lambda (x)
           (if (not (zerop (logand cur_mode (car x))))
             (setq mode$ (strcat mode$ (cadr x)))
           )
         )
        '(
          (0    "_non,")
          (1    "_end,")
          (2    "_mid,")
          (4    "_cen,")
          (8    "_nod,")
          (16   "_qua,")
          (32   "_int,")
          (64   "_ins,")
          (128  "_per,")
          (256  "_tan,")
          (512  "_nea,")
          (1024 "_qui,")
          (2048 "_app,")
          (4096 "_ext,")
          (8192 "_par")
         )
      )
    )
    mode$
  )
(setq OsStr (get_osmode))
(if (setq tmpPt (osnap final OsStr))
  (setq final tmpPt)
)
Put the above right before this line
Code: [Select]
                (drawRect pt1 pt2 ang (* (distance pt1 final) (sin (- (angle pt1 final) ang))))

Hope that makes sense.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

whdjr

  • Guest
Re: Rotated rectangle with osnaps?
« Reply #12 on: November 06, 2007, 04:12:55 PM »
That's too late thru the process Tim.  It needs to occur during the GRREAD function call.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Rotated rectangle with osnaps?
« Reply #13 on: November 06, 2007, 04:57:38 PM »
That's too late thru the process Tim.  It needs to occur during the GRREAD function call.
No because that is the part that actually draws the rectangle, the other part just shows it.  If you want it to show the rectangle, while you drag it, snapping to points, then you have to add it to this part also
Code: [Select]
           (cond ((= code 5)
                  (draw pt1 pt2 data ang)
                 )
You would need to test 'data' to see if it hits something's osnap point; just like we tested 'final' in the portion I posted.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: Rotated rectangle with osnaps?
« Reply #14 on: November 07, 2007, 05:43:05 AM »
Can you not use the built in rectangle command? Or are you after something else? (sorry of this is a silly question)
Thanks for explaining the word "many" to me, it means a lot.