Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dimensions and Selection Sets - Need Help

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
bennywise578
659 Views, 5 Replies

Dimensions and Selection Sets - Need Help

Hey,

 

I have a lisp routine that creates a "frame wall" and I want to be able to automatically dimension said wall within the same routine. I have created two sets of points, each set being on its own new layer. I have made selection sets of each set of points, and want to cycle through each set dimensioning as required. This what I have so far for this part of the routine:

 

;******************************************************************************************************************************************

(command "DIMSCALE" 24)

 

(setq sel1 (ssget "x" '("VPOINTS")))

 

(setq TC (polar (ssname sel1 0) (dtr 180.0) 9))
(command "DIMLINEAR" (ssname sel1 0) (ssname sel1 1)) "V" (polar TC (dtr 180.0) 9) "")
(setq inc 1)
(setq inc2 2)
(while (< inc2 (sslength sel1))
(set (var "TC") (polar (ssname sel1 inc) (dtr 180.0) 9))
(if (= (rem inc2 2) 0)
(command "DIMLINEAR" (ssname sel1 inc) (ssname sel1 inc2) "V" "T" "<> \\X D.L.O." TC "")
(command "DIMLINEAR" (ssname sel1 inc) (ssname sel1 inc2) "V" TC "")
)
(setq inc (+ inc 1))
(setq inc2 (+ inc2 1))
(if (= inc2 (sslength sel1))
(command "DIMLINEAR" (ssname sel1 inc) (ssname sel1 inc2) "V" (polar TC (dtr 180.0) 9) ""
"DIMLINEAR" (ssname sel1 1) (ssname sel1 inc) "V" "T" "<> F.S." (polar TC (dtr 180.0) 9) ""
"DIMLINEAR" (ssname sel1 0) (ssname sel1 inc2) "V" "T" "<> R.O." (polar TC (dtr 180.0) 18) "")
)
)

;****************************************************************************************************************************************

 

When I run the program I get the error: bad point argument. So what I think is happening is that the ssname command is not returning the actual value but just the name? I am new to AutoLisp and even newer to selection sets so be easy... Along with this, I am also curious as to how a selection set is ordered when it is chosen ie how does it determine what would be in (ssname sel1 0). Also, how would one go about deleting the points in these selection sets after the dimensioning has been completed. Any help will be greatly appreciated. Thanks.

5 REPLIES 5
Message 2 of 6
Kent1Cooper
in reply to: bennywise578


@bennywise578 wrote:

.... I have made selection sets of each set of points, and want to cycle through each set dimensioning as required.

....

(setq sel1 (ssget "x" '("VPOINTS")))

 ....

When I run the program I get the error: bad point argument. ....


The error is because '("VPOINTS") is not a point or list of points, which is what (ssget) is looking for if the argument isn't a filter list.  I suspect you're looking for things on a Layer by that name, in which case you need a valid filter list, which would be more like:

 

(setq sel1 (ssget "x" '((8 . "VPOINTS"))))

Kent Cooper, AIA
Message 3 of 6
Kent1Cooper
in reply to: bennywise578


@bennywise578 wrote:

.... I am also curious as to how a selection set is ordered when it is chosen ie how does it determine what would be in (ssname sel1 0). Also, how would one go about deleting the points in these selection sets after the dimensioning has been completed. ....


When selected with (ssget "X"), the order in the selection set comes out in reverse draw order -- last-drawn-first.  When selected by individual picking, the order is the selection order -- first-picked-first.  When using windows, etc., I assume [without testing] that it's probably in selection order, with multiple-things-selected-at-the-same-time in last-drawn-first order within their separate group(s).

 

Use (ssdel) to remove things from the selection set.  You can remove the first thing from one this way:

 

(ssdel (ssname theSet 0) theSet)

 

Or, if you've saved one to a variable, you can remove it this way:

 

(ssdel theVariable theSet)

 

Note that what (ssdel) returns is the altered selection set -- it changes the content of the variable.  You don't need to wrap it in (setq) to update the contents of the variable, the way you do when, for instance, you remove something from a list or a text string.

Kent Cooper, AIA
Message 4 of 6
bennywise578
in reply to: Kent1Cooper

Few quick (maybe) questions...first, what does the "8" signify in (setq sel1 (ssget "X" '((8 . "VPOINTS")))) ? It works, I'm just curious. Secondly, am I accessing the items in the selection set correctly via (ssname sel1 0) for example? I'm now getting this error: Command: ; error: bad argument type: 2D/3D point: <Entity name: 7ffff621f60>. I'm working on the code as we speak and trying out the things you have already mentioned - thanks so much for helping me out.

Message 5 of 6
Kent1Cooper
in reply to: bennywise578


@bennywise578 wrote:

.... what does the "8" signify in (setq sel1 (ssget "X" '((8 . "VPOINTS")))) ? .... Secondly, am I accessing the items in the selection set correctly via (ssname sel1 0) for example? I'm now getting this error: Command: ; error: bad argument type: 2D/3D point: <Entity name: 7ffff621f60>. ....


8 is the DXF or association-list code number that identifies the Layer an object is on.  Type (entget (car (entsel))), and pick something, and it will return the association list, or entity data list, which will have an item in it that looks like this:

 

(8 . "ALayerName")

 

Keep at this stuff for a while, and you'll get used to those association numbers [0 for entity type, 10 for various kinds of points, etc.].

 

The error is from this:
 

(polar (ssname sel1 inc) (dtr 180.0) 9)

 

The (ssname) function returns an entity name, but (polar) wants a point for its 'pt' argument.  You need to extract the point information from the entity, something like this:

 

....

(while (< inc2 (sslength sel1))

  (setq edata (entget (ssname sel1 inc))); get entity data list of first object in selection set
  (set (var "TC") (polar (cdr (assoc 10 edata)) (dtr 180.0) 9)); use its location as origin for (polar)

....
 

That (assoc 10 edata) will return

 

(10 Xcoordinate Ycoordinate Zcoordinate)

 

of the location of a Point, the insertion point of a Block or Text or Mtext, an endpoint of a Line, etc.  Using (cdr) on that returns the point itself, without the 10 associator so that (polar) can use it.

 

[And by the way, if all your relative-location angles are at 180 degrees, you could skip the (dtr) function entirely, and just use pi in place of (dtr 180.0) for the 'ang' arguments in your (polar) functions.]

Kent Cooper, AIA
Message 6 of 6
bennywise578
in reply to: Kent1Cooper

Thanks so much for your help. Everything ended up working just fine. My apologies for the double post. Thanks again. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost