Lord V Posted June 22, 2010 Share Posted June 22, 2010 ok my brain is a little frazzled this afternoon and its a long long time since I have written a lisp. I need a line in a lisp to select all objects that have a common point (in this case the start point of a polyline and the insertion points of block attributes in order to turn them into a block) What should I be writting? Im ending up in a nightmare of ssget, ssadd, entsel and every other half remembered function. (re-learning lisp with a stinking head cold is never a great idea by the way Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 22, 2010 Share Posted June 22, 2010 You may only need one ssget call. Something like this: (ssget "X" (list (cons 10 pt))) where pt is that common point. That should work for the starting point of a polyline, insertion point of block and insertion point of text. It'll select everything that has a DXF group code 10 associated with that point. I think group 10 is the most common for insertion point, but check here just in case: http://autodesk.com/techpubs/autocad/acad2000/dxf/ Quote Link to comment Share on other sites More sharing options...
Lord V Posted June 22, 2010 Author Share Posted June 22, 2010 I keep getting "bad ssget list value", although as far as i can see 10 should work. Unless im missing something.... which is likely.... Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 22, 2010 Share Posted June 22, 2010 Check the point you're passing to the function. (ssget "X" (list (cons 10 (list 0 0 0)))) will work, because DXF code 10 is getting a list, which it wants. This, however, won't: (ssget "X" (list (cons 10 "why hello thar"))) because code 10 doesn't like strings. Quote Link to comment Share on other sites More sharing options...
Lord V Posted June 22, 2010 Author Share Posted June 22, 2010 I will admit im now baffled. This is what I have written for selecting the polyline and attribute definitions and converting to block: (ssget "x" (list (cons 10 (list 976.1774 821.7919 0.00)))) (command "block" "populate" "976.1774,821.7919") (Command "insert" "populate" "976.1774,821.7919" "" "" "" "" "" "") whence have I gone wrong? (other then everywhere) .... Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 22, 2010 Share Posted June 22, 2010 Ahh, I see what you did there. Bit of advice, whenever I work with command line calls like that and I'm getting error after error, I generally start with the first command call and keep daisy chaining it until I get it to work. That is to say, start with: (command "block") and see what happens. Then, (command "block" "populate") and see what happens. Then, (command "block" "populate" "976.1774,821.7919") and see what happens. Fortunately, in this case, it's easy to see once you do that. I'll save you the trouble: the block command needs the objects. You've gathered them nicely with your ssget call, but now you need to put those into the command function where you create your block. This should come just after the "976.1774,821.7919", which you'll see when you get there (the command prompt asks you for the objects you want). Also, keep in mind that the ssget call MAY return nil, which will screw up your command call to create the block, and whatever else may come after. Quote Link to comment Share on other sites More sharing options...
Lord V Posted June 22, 2010 Author Share Posted June 22, 2010 never mind... fixed it. Cheers for your help . Quote Link to comment Share on other sites More sharing options...
Lord V Posted June 22, 2010 Author Share Posted June 22, 2010 Thanks for the quick reply... as I said my brain is seriously addled.... :-) Realised what I was doing wrong pretty much as I posted my question. Thanks though! Quote Link to comment Share on other sites More sharing options...
Freerefill Posted June 22, 2010 Share Posted June 22, 2010 Happy to help ^.^ Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted June 22, 2010 Share Posted June 22, 2010 Question unrelated to this problem but I think it falls under a dumb question. I've selected my dynamic block with ssget, now how do I change the dynamic block length? I'm using one of Alan J's codes that works when inserting a block but is this the way to go when changing an existing block? (vl-load-com) ((lambda (block) (foreach x (vlax-invoke block 'GetDynamicBlockProperties) (and (eq (vla-get-propertyname x) "Distance1") (vla-put-value x (distance p1 p2) ) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 22, 2010 Share Posted June 22, 2010 There's no such thing as a dumb question, only dumb people. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 22, 2010 Share Posted June 22, 2010 Select the existing block and convert it to a VLA-Object, then modify the properties as per Alan's example. Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted June 22, 2010 Share Posted June 22, 2010 thanks for pointing me in the right direction Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 22, 2010 Share Posted June 22, 2010 These may also help - they need a bit of a rewrite, but they should work: http://www.cadtutor.net/forum/showpost.php?p=323818&postcount=4 Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted June 22, 2010 Share Posted June 22, 2010 I actually saved this a while back... I don't know why I didn't go back to it. I'm an idiot! Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 22, 2010 Share Posted June 22, 2010 You're welcome Quote Link to comment Share on other sites More sharing options...
Lord V Posted June 23, 2010 Author Share Posted June 23, 2010 As I am a dumb person: I am currently writting two lisp routines that are (in theory) designed to repeat the same set of commands for "n" number of entities. Now both have the same error. The first repetition works fine. However the second time round it throws up the error "too few arguments". anyway here are the codes: ;============ Noise-RD.LSP ================== ;By Tristan Sly ;============================================ ; (Defun C:NRD () (command "layer" "new" "G0-18h-DoMin-F" "") ;Create layer for pl (command "layer" "new" "G0-18h-DoMin-Tag" "") ;Create layer for tag (command "layer" "new" "G0-18h-DoMin-Block" "") ;Create layer for block (command "change" "all" "" "p" "LA" "G0-18h-DoMin-F" "") ; move rd plines to layer (command "layer" "set" "G0-18h-DoMin-Tag" "") ; set layer (command "attdef" "" "tag" "prompt" "defaultvalue" "976.1774,821.7919" "2.500" "0" ) ; Create attribute 1 (command "attdef" "" "tag2" "prompt2" "defaultvalue2" "976.1774,821.7919" "2.500" "0" ) ; Create attribute 2 (command "attdef" "" "tag3" "prompt3" "defaultvalue3" "976.1774,821.7919" "2.500" "0" ) ; Create attribute 3 (command "layer" "set" "G0-18h-DoMin-Block" "") ; set layer (command "block" "populate" "976.1774,821.7919,0.000" (ssget "x" (list (cons 10 (list 976.1774 821.7919 0.00)))) "") ;create block (Command "insert" "populate" "976.1774,821.7919" "" "" "" "" "" "") (command "layer" "set" "G0-18h-DoMin-Tag" "") ; set layer (command "attdef" "" "tag" "prompt" "defaultvalue" "1463.9181,758.8268" "2.500" "0" ) ; Create attribute 1 (command "attdef" "" "tag2" "prompt2" "defaultvalue2" "1463.9181,758.8268" "2.500" "0" ) ; Create attribute 2 (command "attdef" "" "tag3" "prompt3" "defaultvalue3" "1463.9181,758.8268" "2.500" "0" ) ; Create attribute 3 (command "layer" "set" "G0-18h-DoMin-Block" "") ; set layer (command "block" "populate1" "1463.9181,758.8268,0.000" (ssget "y" (list (cons 10 (list 1463.9181 758.8268 0.00)))) "") ;create block (Command "insert" "populate1" "1463.9181,758.8268" "" "" "" "" "" "") ;repeat ad nauseum (command "attdisp" "off") (Princ) ;clean exit ) (princ "\n\tc:type NRD to start") and ;============ Noise-RDL.LSP ================== ;By Tristan Sly ;============================================ ; (Defun C:NRDL () (command "layer" "new" "me" "") (command "change" (ssget "x" (list (cons 10 (list 976.1774 821.7919 0.00)))) "" "p" "la" "me" "" "") (command "layer" "new" "me1" "") (command "change" (ssget "y" (list (cons 10 (list 1635.2095 560.6183 0.00)))) "" "p" "la" "me1" "" "") (Princ) ) (princ "\n\tc:type NRDL to start") I am guessing its to do with the second ssget as it is at that point in both the error occurs, but I dont understand why as it works fine for the first entity. Help please! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 23, 2010 Share Posted June 23, 2010 I don't think an ssget mode 'y' exists. Have a read of this: SSGET the underscore (_) is needed with W, F, WP, :S but not with X, A, C, CP, I, L, P, :E ... (ssget '(2 2)) Create a selection set of the object passing through (2,2): +. The undocumented “+.” mode forces (ssget) to remain in “point” mode, similar to setting PickAuto to 0.... the "+." puts (ssget) into "point" mode. It helps the ":S" single-mode act just like (entsel) by avoiding implied selection windows. A All like "X" but filters frozen out Selects all objects on thawed layers. B Box Selects all objects inside or crossing a rectangle specified by two points. If the rectangle's points are specified from right to left, Box is equivalent to Crossing. Otherwise, Box is equivalent to Window. C Crossing Simular to Window selection Selects objects within and crossing an area defined by two points. A crossing selection is displayed as dashed or otherwise highlighted to differentiate it from window selection. Specifying the corners from right to left creates a crossing selection. *** (Specifying the corners from left to right creates a window selection.) (ssget "_C" '(0 0) '(1 1)) Caution: the area must be on the screen for this to work properly - CAB CP Crossing Polygon Selects objects within and crossing a polygon defined by specifying points. The polygon can be any shape but cannot cross or touch itself. AutoCAD draws the last segment of the polygon so that it is closed at all times. CPolygon is not affected by the PICKADD system variable. (ssget "_CP" '((1 1)(3 1)(5 2)(2 4))) Example with filters (ssget "_CP" '(Point list) '(Filter List)) (setq ss (ssget "_CP" '((0 0)(10 0)(10 10)(0 10)) '((0 . "INSERT") (66 . 1)) )) Caution: the area must be on the screen for this to work properly - CAB (vl-cmdf "._zoom" "_E") ; Extents Duplicates OK, else duplicates are ignored :E Everything in aperture Everything within the cursor's object selection pickbox. F Fence Selects all objects crossing a selection fence. The Fence method is similar to CPolygon except that AutoCAD does not close the fence, and a fence can cross itself. Fence is not affected by the PICKADD system variable. G Groups Selects all objects within a specified group. I Implied Implied selection (objects selected while PICKFIRST is in effect). L Last Last visible object added to the database :L Rejects locked layers M Multiple Specifies multiple points without highlighting the objects, thus speeding up the selection process for complex objects. The Multiple method also selects two intersecting objects if the intersection point is specified twice. :N Nested Call ssnamex for additional information on container blocks and transformation matrices for any entities selected during the ssget operation. This additional information is available only for entities selected via graphical selection methods such as Window, Crossing, and point picks. Unlike the other object selection methods, :N may return multiple entities with the same entity name in the selection set. For example, if the user selects a subentity of a complex entity such as a BlockReference, PolygonMesh, or old style polyline, ssget looks at the subentity that is selected when determining if it has already been selected. However, ssget actually adds the main entity (BlockReference, PolygonMesh, etc.) to the selection set. The result could be multiple entries with the same entity name in the selection set (each will have different subentity information for ssnamex to report). P Previous Selects the most recent selection set. The Previous selection set is cleared by operations that delete objects from the drawing. AutoCAD keeps track of whether each selection set was specified in model space or paper space. The Previous selection set is ignored if you switch spaces. Rejects Viewport :R Allows entities in a long transaction to be selected. :S Force single object selection only :U Enables subentity selection - 2006+ Cannot be combined with the duplicate (":D") or nested (":N") selection modes. In this mode, top-level entities are selected by default, but the user can attempt to select subentities by pressing the CTRL key while making the selection. This option is supported only with interactive selections, such as window, crossing, and polygon. It is not supported for all, filtered, or group selections. :V Forces subentity selection - 2006+ Treats all interactive, graphic selections performed by the user as subentity selections. The returned selection set contains subentities only. This option cannot be combined with the duplicate (":D") or nested (":N") selection modes. This option is supported only with interactive selections, such as window and crossing. It is not supported for all, filtered, or group selections. W Window Selects all objects completely inside a rectangle defined by two points. Specifying the corners from left to right creates a window selection. (Specifying the corners from right to left creates a crossing selection.) WP Window Polygon Selects objects completely inside a polygon defined by points. The polygon can be any shape but cannot cross or touch itself. AutoCAD draws the last segment of the polygon so that it is closed at all times. WPolygon is not affected by the PICKADD system variable. X Extended search (search whole database) Entire database. If you specify the X selection method and do not provide a filter-list, ssget selects all entities in the database, including entities on layers that are off, frozen, and out of the visible screen. Also at the command prompt "Select objects:" you can enter Add, Remove, Undo, :U Enables subentity selection. Cannot be combined with the duplicate (":D") or nested (":N") selection modes. In this mode, top-level entities are selected by default, but the user can attempt to select subentities by pressing the CTRL key while making the selection. This option is supported only with interactive selections, such as window, crossing, and polygon. It is not supported for all, filtered, or group selections. :V Forces subentity selection. Treats all interactive, graphic selections performed by the user as subentity selections. The returned selection set contains subentities only. This option cannot be combined with the duplicate (":D") or nested (":N") selection modes. This option is supported only with interactive selections, such as window and crossing. It is not supported for all, filtered, or group selections. Systen Var PICKADD controls whether subsequent selections replace the current selection set or add to it. Quote Link to comment Share on other sites More sharing options...
Lord V Posted June 23, 2010 Author Share Posted June 23, 2010 That makes sense, however when I repeat "x" mode it still fails. Instead of running the ssget it tries to repeat the defun. but only on the layer one, for some reason the block one is now working. I get the following from the command line: c:type NRDL to start Command: Command: nrdl layer Current layer: "0" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: new Enter name list for new layer(s): me Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: Command: change Select objects: 1 found Select objects: Specify change point or [Properties]: p Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/Material/Annotative]: la Enter new layer name <0>: me Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness/Material/Annotative]: Command: NRDL Unknown command "NRDL". Press F1 for help. Command: layer Current layer: "0" Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: new Enter name list for new layer(s): me1 Enter an option [?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock /stAte]: Command: change Select objects: Command: NRDL Unknown command "NRDL". Press F1 for help. Command: p Unknown command "P". Press F1 for help. Command: la Unknown command "LA". Press F1 for help. Command: me1 Unknown command "ME1". Press F1 for help. Command: NRDL Unknown command "NRDL". Press F1 for help. Command: NRDL Unknown command "NRDL". Press F1 for help. Command: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 23, 2010 Share Posted June 23, 2010 The Unknown command you are receiving it when the "" that are used are trying to repeat the command. The ssget was perhaps returning nil to the command line, hence cancelling the command, and so the "" were trying to repeat the last command. 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.