anishtain4 Posted March 12, 2012 Share Posted March 12, 2012 I want to draw a rectangle with defined width and length that but the user selects insertion point and rotation. but the thing is that I want user sees the object when s/he is pointing the insertion point, like blocks when you insert them Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 12, 2012 Share Posted March 12, 2012 You should use the first point as argument to second interogation (may use GETCORNER instead of GETPOINT): (setq Point1st (getpoint "\First corner: ") Point2nd (getcorner Point1st "\nSecond corner: ")) Regards, Mircea Quote Link to comment Share on other sites More sharing options...
anishtain4 Posted March 12, 2012 Author Share Posted March 12, 2012 I know this but the object is not displayed while you are selecting first or second point, I want that Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 12, 2012 Share Posted March 12, 2012 Sorry, I think I misread your first statement. You are looking to preview a custom shape and his orientation dinamically? For this you should check the GRREAD, GRDRAW and GRVECS functions - you will find some great examples here on Forum. Regards, Mircea Quote Link to comment Share on other sites More sharing options...
VVA Posted March 12, 2012 Share Posted March 12, 2012 I think this can be made by using grread Examples of usage GRREAD - let's share displaying any text near the cursor on the screen [grread + grvecs] http://www.theswamp.org/index.php?action=search2 Quote Link to comment Share on other sites More sharing options...
anishtain4 Posted March 12, 2012 Author Share Posted March 12, 2012 Yes this is exactly what I was after, thanks a lot Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 12, 2012 Share Posted March 12, 2012 The grread function will pause for a form of user input and then return information about the user input detected, whether it be cursor position, mouse clicks or keyboard input. When used within a while loop, you can continuously monitor user input and update the display accordingly. However, a major disadvantage with the grread function is that, whilst pausing for user input, all standard AutoCAD functionality is disabled. This means the user has no access to Object Snap, Tracking, Orthomode etc. This trade-off just to achieve a fancy effect is usually not an option for most drafting operations. An alternative for your task might be to use the various options offered by the in-built RECTANG command, for example: (defun c:MyRec ( / p1 ) (if (setq p1 (getpoint "\nSpecify First Corner: ")) (progn (command "_.rectang" "_non" p1 "_D" 4 2) (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted March 12, 2012 Share Posted March 12, 2012 I want to draw a rectangle with defined width and length that but the user selects insertion point and rotation... (defun C:TEST ( / ss len wd el) (if (not (tblsearch "BLOCK" "MyRectangle")) (progn (setq ss (ssadd) ss (ssadd (entmakex '((0 . "LINE") (10 0.0 0.0 0.0) (11 1.0 0.0 0.0))) ss) ss (ssadd (entmakex '((0 . "LINE") (10 1.0 0.0 0.0) (11 1.0 1.0 0.0))) ss) ss (ssadd (entmakex '((0 . "LINE") (10 1.0 1.0 0.0) (11 0.0 1.0 0.0))) ss) ss (ssadd (entmakex '((0 . "LINE") (10 0.0 1.0 0.0) (11 0.0 0.0 0.0))) ss) ) (command "BLOCK" "MyRectangle" '(0 0 0) ss "") ) ) (if (and (setq len (getdist "\Length: ")) (setq wd (getdist "\Width: ")) ) (progn (setq el (entlast)) (command "INSERT" "MyRectangle" "X" len "Y" wd) (while (= 1 (getvar 'cmdactive)) (command pause) ) (if (not (eq el (entlast))) (command "EXPLODE" "L" "" "PEDIT" "M" "P" "" "Y" "J" "" "") ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 12, 2012 Share Posted March 12, 2012 Nice one Stefan. If you don't mind, I will make some comments: Try to disable CMDECHO to have a clean impact on prompt. To make this more dynamical may ask for size first and build the "icon" at scale; purge it when no longer useful. There is no need to close selection cycle when use EXPLODE command.(command "EXPLODE" "L" [color=red]""[/color]) Regards, Mircea Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 12, 2012 Share Posted March 12, 2012 Nice idea Stefan, here is a little refinement of your code, I hope you don't mind: ([color=BLUE]defun[/color] c:brec ( [color=BLUE]/[/color] *error* _getdist en va vr ) [color=GREEN];; Block Rectangle[/color] [color=GREEN];; By Lee Mac, based on ideas by Stefan BMR[/color] ([color=BLUE]defun[/color] *error* ( msg ) ([color=BLUE]if[/color] va ([color=BLUE]mapcar[/color] '[color=BLUE]setvar[/color] vr va)) ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg) [color=MAROON]"*BREAK,*CANCEL*,*EXIT*"[/color])) ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nError: "[/color] msg)) ) ([color=BLUE]princ[/color]) ) ([color=BLUE]if[/color] ([color=BLUE]null[/color] ([color=BLUE]tblsearch[/color] [color=MAROON]"BLOCK"[/color] [color=MAROON]"$MyRectangle$"[/color])) ([color=BLUE]progn[/color] ([color=BLUE]entmake[/color] '( (0 . [color=MAROON]"BLOCK"[/color]) (8 . [color=MAROON]"0"[/color]) (2 . [color=MAROON]"$MyRectangle$"[/color]) (10 0.0 0.0 0.0) (70 . 0) ) ) ([color=BLUE]entmake[/color] '( (0 . [color=MAROON]"LWPOLYLINE"[/color]) (100 . [color=MAROON]"AcDbEntity"[/color]) (100 . [color=MAROON]"AcDbPolyline"[/color]) (8 . [color=MAROON]"0"[/color]) (90 . 4) (70 . 1) (10 0.0 0.0) (10 1.0 0.0) (10 1.0 1.0) (10 0.0 1.0) ) ) ([color=BLUE]entmake[/color] '( (0 . [color=MAROON]"ENDBLK"[/color]) (8 . [color=MAROON]"0"[/color]) ) ) ) ) ([color=BLUE]defun[/color] _getdist ( a b c ) ([color=BLUE]set[/color] a ([color=BLUE]cond[/color] ( ([color=BLUE]getdist[/color] ([color=BLUE]strcat[/color] b [color=MAROON]" <"[/color] ([color=BLUE]rtos[/color] ([color=BLUE]set[/color] a ([color=BLUE]cond[/color] ( ([color=BLUE]eval[/color] a) ) ( c )))) [color=MAROON]">: "[/color] ) ) ) ( ([color=BLUE]eval[/color] a) ) ) ) ) ([color=BLUE]setq[/color] vr '(CMDECHO QAFLAGS) va ([color=BLUE]mapcar[/color] '[color=BLUE]getvar[/color] vr) ) ([color=BLUE]mapcar[/color] '[color=BLUE]setvar[/color] vr '(0 1)) (_getdist '*len* [color=MAROON]"\nSpecify Length"[/color] 1.0) (_getdist '*wid* [color=MAROON]"\nSpecify Width"[/color] 1.0) ([color=BLUE]setq[/color] en ([color=BLUE]entlast[/color])) ([color=BLUE]command[/color] [color=MAROON]"_.-insert"[/color] [color=MAROON]"$MyRectangle$"[/color] [color=MAROON]"_X"[/color] *len* [color=MAROON]"_Y"[/color] *wid*) ([color=BLUE]princ[/color] [color=MAROON]"\nSpecify Insertion Point: "[/color]) ([color=BLUE]setvar[/color] 'CMDECHO 1) ([color=BLUE]while[/color] ([color=BLUE]=[/color] 1 ([color=BLUE]logand[/color] 1 ([color=BLUE]getvar[/color] 'CMDACTIVE))) ([color=BLUE]command[/color] [color=BLUE]pause[/color]) ) ([color=BLUE]setvar[/color] 'CMDECHO 0) ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]equal[/color] en ([color=BLUE]setq[/color] en ([color=BLUE]entlast[/color])))) ([color=BLUE]command[/color] [color=MAROON]"_.explode"[/color] en [color=MAROON]""[/color]) ) ([color=BLUE]mapcar[/color] '[color=BLUE]setvar[/color] vr va) ([color=BLUE]princ[/color]) ) Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted March 12, 2012 Share Posted March 12, 2012 Lee, But of course I do not mind ... Sometimes I'm just too lazy to add error traps, SysVar ping-pong or fancy memorized inputs... It was just an idea to play with... Your improved version is excellent as usual... Mircea, mersi mult... Cum am spus, a fost doar o idee.. Apropo, crezi ca am avut sanse sa ne intalnim? Am terminat la Brasov UT-ul in '94. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 12, 2012 Share Posted March 12, 2012 Thanks Stefan! Quote Link to comment Share on other sites More sharing options...
anishtain4 Posted March 12, 2012 Author Share Posted March 12, 2012 Thanks stephan, that works perfectly. I was thinking about something like this but I couldn't make it work. there is no way to imitate block? for example with pasteclip you can do it on placement but not rotation Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 12, 2012 Share Posted March 12, 2012 Stefan, you have my answer on PM. Thank you. Regards, Mircea Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.