Running Non-Native (Carlson) command within Lisp and inputting Prompts

Running Non-Native (Carlson) command within Lisp and inputting Prompts

MMillsLEUBZ
Participant Participant
468 Views
4 Replies
Message 1 of 5

Running Non-Native (Carlson) command within Lisp and inputting Prompts

MMillsLEUBZ
Participant
Participant

Good morning, 

I will start with the confession that I only began learning AUTOLISP two days ago and education has included reading a portion of the AUTOLISP Dev Guide and watching introductory youtube videos, so forgive me if I fumble here and there. I know exactly what I am trying to achieve with this first coding venture but have questions about how to go about it. I think this is in the end a "simple" goal but it could help me immensely with my daily work. 

 

My objective is to write an autolisp to improve the Carlson specific FPNT command. I am running CARLSON 2021 on ACAD 2020. 

 

HOW THE EXISTING COMMAND WORKS

The basic function of the existing command is to create arrows highlighting and centering the screen on existing Carlson point entities.  Upon running FPNT, it prompts to enter N to search by point number or D to search by description. Selecting "n", "enter", it prompts for number (or number range). Hitting enter again will highlight and center on those point numbers. 

 

WHAT I WANT TO MAKE IT DO WITH A NEW COMMAND

I am trying to write a LISP that will exploit the potential of FPNT since I often have to quality check hundreds of these points. My command would ideally prompt for a starting number. The code would then automatically run FPNT, select N to search by number, and enter previously prompted number.  AND THEN allow Command would allow the user to press left and right arrow keys to add or subtract to that number rerunning FPNT each time effectively allowing me to "walk" the database point by point. 

 

MY ISSUE SO FAR:

I am not sure how to run the command and then give further inputs (like selecting N and entering point number).

 

Things I have tried are:

Running (c:fpnt) initiates the function but pauses the Autolisp until command is terminated. It does so in the visual LISP Console as well as the command prompt. 

 

One tutorial gave an example of running 

(command "-layer" "m" "layer1 "C" 8 "" "P" "N" "" "") to create a new layer customizing the prompts. This is what I am trying to do but any attempt to use the command function as (command "FPNT") or (Command "c:fpnt") returns "Unknown command". I think this has to do with FPNT being a Carlson specific command rather than original ACAD command. It exists in the Program Files as an encrypted LSP file "FPOINT.fas" if that helps. 

I did find out if I paste "Fpnt n 4 " (no quotes) into the command prompt it runs the command, selects search by number and finds pt 4 instantaneously. I cannot figure how to replicate this by running in a lisp though. 

 

So that's where I am at! If you have read this far, thank you for checking out my post! Any help is super appreciated!

~ MM

0 Likes
Accepted solutions (1)
469 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try these lines, one after another copy-paste to the command-line.

 

(vl-load-com)
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "fpnt\rN\r20\r"))

Message 3 of 5

MMillsLEUBZ
Participant
Participant

That works in the command line! Thank you thank you! That should gets me back on track. Will this line work to replace 20 with a defined symbol?

0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant

Try these commands. Not sure how to get from one FPNT highlighted selection to another - REGEN? Might need to add that. I don't know, don't have the SW.

 

Arrows L/R won't be possible for sure. Try commands like F+, F- ... or something similar.

 

(defun c:FX ()
  (if (setq *fpntx* (getint "Specify number: "))
    (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "fpnt\rN\r" (itoa *fpntx*) "\r")))
  (princ)
  )

(defun c:F+ ()
  (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "fpnt\rN\r" (itoa (setq *fpntx* (1+ *fpntx*))) "\r"))
  (princ)
  )

(defun c:F- ()
  (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "fpnt\rN\r" (itoa (setq *fpntx* (1- *fpntx*))) "\r"))
  (princ)
  )

 

BTW it's not a SYMBOL. That term is used for function names. You mean a "variable"

Message 5 of 5

MMillsLEUBZ
Participant
Participant

Thank you for the correction! And your code worked! Well, it worked for a minute. After a couple of instances, something in the code is causing Carlson to read the CRD file (the linked file where all points are stored separate from the drawing) to be locked by the program. I get the error:

Error 1: Could not open file: C:\PROJECTS\PROJECTNAME.crd
It might be read-only, in use by another application
or locked in error by program. If locked, restart program.
Error: unable to open file 'C:\PROJECTS\PROJECTNAME.crd'.

and it is throwing this error for these commands or any command that uses the crd file. 

 

This may need to be something that I figure out but I super appreciate the help in getting me here!

0 Likes