AJRight Posted May 3, 2013 Posted May 3, 2013 Hello all, I am writing this lisp to fix some software's shortcomings when it is exported from said program (which shall not be named) to a DXF format. The issue is when it is exported, it explodes a block made in the unnamed program and it is offset from the center of the hexagon where the number for that note should reside. This lisp routines purpose is to filter out the note number and move them back to the centers of these hexagons through out the drawing. This distance and angle is consistent with all the notes which makes it a little easier to manage. However when I get to the move point in my code and specify a polar direction to move the mtext note values, I get ; error: bad argument type: 2D/3D point: nil and I am not sure where I went wrong. Any help is appreciated. Here's my code thus far: ;;; Purpose: To move notes a set distance at a set angle to fix note block that are otherwise ruined duing importing (DEFUN C:NTEST (/) (COMMAND "-LAYER" "M" "TEMP" "" ) ;;; CREATES TEMP LAYER FOR ISOLATION (SETQ TMP (ssget "_x" ' ((0 . "MTEXT") (1 . "0.*")))) ;;; FILTERS ZERO VALUES (COMMAND "CHPROP" TMP "" "LA" "TEMP" "" ) ;;; MOVES ZERO VALUES TO A TEMP LAYER FOR ISOLATION (COMMAND "-LAYER" "LO" "TEMP" "" ) ;;; LOCKS TEMP LAYER SO THAT ACCIDENTAL WILD CARD MATCHES OF ZERO ARE NOT MOVED (SETQ LST (GETINT "\nEnter last note number..(05...10..20)..> ")) ;;; USER SPECIFIES LAST NOTE NUMBER IN DXF DRAWING (SETQ GRP (ssget "_x" ' ((0 . "MTEXT") (-4 . "<and") (1 . "0*, 'LTS'")))) ;;; SEARCHES NOTES ;;; DRAGONS LIE AHEAD. UNRESOLVED ISSUES (SETQ IP (CDR (ASSOC 10 GRP))) (COMMAND ".MOVE" GRP "" IP (polar IP (* pi 1.75)0.2171)) ;;; THESE ARE KNOWN TO BE THE CORRECT OFFSET DISTANCE AND ANGLE AND SHOULD NOT BE MODIFIED. ;;; I SHOULD BE GOOD FROM HERE DOWN (COMMAND "-LAYER" "U" "*" "") ;;; UNLOCK TEMP LAYER TO RETURN TO NORMAL AND DELETE TEMP LAYER (COMMAND "-LAYER" "S" "0" "" ) ;;; SETS THE LAYER BACK TO ZERO (COMMAND "CHPROP" TMP "LA" "0" "" ) ;;; CHANGES ITEMS FROM TEMP LAYER TO LAYER ZERO USING PREVIOUS SELECTION SET FILTER (COMMAND "._LAYDEL" "NAME" "TEMP" "" "Y" "" ) ;;; DELETE TEMP LAYER (PROMPT "N\ Notes are now fixed.") ;;; INFORM USER ;(PRIN1 LST) ;;; FOR TESTING ONLY. NOT TO BE USED (PRINC) );;; end defun Thanks again guys. Quote
MSasu Posted May 3, 2013 Posted May 3, 2013 It will be very useful to post a sample of the mtext items you were looking to get selected. I cannot be 100% sure until see the actual case, but seems that you should write the filter like: (ssget "_x" ' ((0 . "MTEXT") (1 . "0*,'LTS'"))) or (ssget "_x" ' ((0 . "MTEXT") (-4 . "<or") (1 . "0*") (1 . "'LTS'") (-4 . "or>"))) Also, you should be careful how access the selection set: [color=red](if GRP (progn[/color] (SETQ IP (CDR (ASSOC 10 [color=red](ssname [/color]GRP[color=red] 0)[/color]))) (COMMAND ".MOVE" GRP "" IP (polar IP (* pi 1.75) 0.2171)[color=red])[/color] ... [color=red] ) )[/color] However, since you are intersted to move the items by a given distance, the location of reference point doesn't matter: (SETQ IP [color=blue]'(0.0 0.0)[/color]) (COMMAND ".MOVE" GRP "" IP (polar IP (* pi 1.75) 0.2171)) Quote
AJRight Posted May 3, 2013 Author Posted May 3, 2013 MSasu, Thanks for your reply. The main dilemma is that every entity is on layer zero. That is how the software exports its drawings for use in AutoCAD. It's very annoying so my filtering options are limited thus why I only filter by text. The notes the user is looking for range from 01 to what ever they specify in that getint prompt. But after testing that filtering method initially with finding a range of number between 0* and the user specified number is that it would pick up zero values for equipment where we had no load. For Example, in our office we will often generate one lines from our previous work or others and create a new fresh set for a contractor to mark up. If more information is needed, we would leave it blank however, the software does not allow for blank input values so zero is the only acceptable alternative. This presents a problem for me because I have to filter those 0.00A (V) (kV) or whatever units is attributed to that value. I don't know if that helps shed anymore light on my situation but I am gonna give your code suggestions a try here. Quote
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.