I'm working on this LISP that inserts blocks based on node points and then rotates the inserted block towards the nearest line based on layer. For select blocks, will also move the block to the nearest point.
I've attached the full LISP, because it is a longer LISP file. Below are more specific areas of noting.
Currently, I'm getting an error of "Command: BLI ; error: bad argument type: lselsetp nil".
The insert block based on the node point is what we have had, and currently works as intended.
Within the BLINS_BlockFunction, the part that I am adding with the angle and closest point. If the "Adjust Insert" is 0, then it won't move to the nearest wall line. If it is 1, then it will move. Not all blocks are expected to move to the nearest wall line.
(defun BLINS_BlockFunction (myBLILayer myBlockName myBlockLayer myVisibility myAA AIns)...(setq pt (cdr (assoc 10 enlist))) ; declare the point (pt) variable(setq myAngle (BLINS_GetAngle pt myAA)) ; set angle of block insertion.(if (= AIns 0) ;If Adjust Insert = 0, then keep closestpt the same as insertion point. (setq closestpt pt))(if (= AIns 1) ;If Adjust Insert = 1, then set closestpt to nearest wall line. (setq closestpt myPointTMP)) ;myPointTMP is set in the BLINS_GetAngle function.(command "_-insert" myBlockName closestpt 1 myAngle "")...
Determining the Angle
With an earlier version of the code, prior to the error I started getting, it would insert the block at 180 degrees, plus the specified angle noted in the syntax. Even if there was an odd angled wall line near the insertion point.
What is expected is that it determines the angle to the line, and then adds the angle from the syntax. The reason for this is to make sure the block comes in perpendicular to the line.
I got the angle portion working, and if AINS variable is set to 0.
Now, it is down to the portion of if AINS variable is set to 1, that it would move to the nearest point based on the baseline. This could either be done by moving the block after insertion or the node point prior to insertion. I've been trying different ways to get it to work.
(if (= AIns 1) ;If Adjust Insert = 1, move node to location of nearest wall line. ((if BLINSBaselineSet (progn (setq count 0) (while (< count (sslength BLINSBaselineSet)) ; WHILE the length of the set (pointSet) is less than the counter (cnt) (setq enamed (ssname BLINSBaselineSet cnt)) ; use the SSName function to assign the value from the counter to the (pointSet) variable (setq nearpt (vlax-curve-getClosestPointTo enamed myPoint)) ; declare the point (pt) variable (setq count (+ count 1)) );end while );end progn ) (vla-move epoint pt nearpt) (setq closestpt nearpt) ))
Trying to get the nearest location from the node to the line selection set. Then moving the node from the location spot to that nearest point.
I've been getting errors of: "bad argument type: VLA-OBJECT" or "bad argument type: 2D/3D point: nil"
I've gotten this LISP close to done. Working with one node point, I got it to work, thought it was done. Then when testing with more node points, getting... undesirable results.
I put in 3 of the same type of node for block to insert on. First one came in perfect. Second one appears, but then is deleted. The third never appears. I also put in a node for a ceiling light block, that the location of won't be adjusted. The block comes in extremely stretched for some odd reason.
I've attached a sample drawing and update of current LISP.
BLI Test.dwg
BLINS_Main - 0015.LSP