Help with insert block with attribute prompt and Visibility

Help with insert block with attribute prompt and Visibility

murmanator
Advocate Advocate
890 Views
5 Replies
Message 1 of 6

Help with insert block with attribute prompt and Visibility

murmanator
Advocate
Advocate

Hello, Im having trouble with this program in trying to modify it to have an attribute prompt included. The program as it sits works fine to insert the block and set the Visibility state. I wanted to change it so that the user is prompted for the attribute value upon insertion, the same way it would if you were just manually inserting the block. I tried doing this with the -INSERT function (removing the last quotes), and it did insert the block with the attribute prompt but the Visibility part failed.

 

(vl-cmdf "-INSERT" "UtilityLocator_DYN" PNT "" "" "")

 

I also tried adding in a setpropertyvalue function after the Visibility state line, and it worked for visibility but the attribute part didnt work. Im sure I have something wrong after the attribute name here, I tried a few things this was just the last attempt.

 

(setpropertyvalue (entlast) "DIST" (command pause))

 

Ive attached the block below. Ive had problems with this before and never really understood a good way to make it work. Thanks in advance for any help.

 

The main program:

 

(DEFUN C:UTIL () (UTIL NIL))
(DEFUN UTIL (TYP)
(GV)
(0V)
(SETVAR 'CLAYER "PLUMBING-EQUIP")
(IF (NULL TYP)
(PROGN (INITGET "Equipment AirConditioner ElectricBox GasStub HoseBib")
(SETQ TYP (COND ((GETKWORD
"\nSpecify Marker [Equipment/AirConditioner/ElectricBox/GasStub/HoseBib] <ElectricBox>: "
)
)
("ElectricBox")
)
)
)
)
(SETQ PNT (GETPOINT "\n\t\t =>> Pick a Location <<= "))
(if PNT
(progn
(vl-cmdf "-INSERT" "UtilityLocator_DYN" PNT "" "" "" "")
(chgdynprop (entlast) "Visibility" TYP)
)
)
(SV)
(PRINC)
)

0 Likes
Accepted solutions (1)
891 Views
5 Replies
Replies (5)
Message 2 of 6

dlanorh
Advisor
Advisor
Accepted solution

 


@murmanator wrote:

Hello, Im having trouble with this program in trying to modify it to have an attribute prompt included. The program as it sits works fine to insert the block and set the Visibility state. I wanted to change it so that the user is prompted for the attribute value upon insertion, the same way it would if you were just manually inserting the block. I tried doing this with the -INSERT function (removing the last quotes), and it did insert the block with the attribute prompt but the Visibility part failed.

 

(vl-cmdf "-INSERT" "UtilityLocator_DYN" PNT "" "" "")

 

I also tried adding in a setpropertyvalue function after the Visibility state line, and it worked for visibility but the attribute part didnt work. Im sure I have something wrong after the attribute name here, I tried a few things this was just the last attempt.

 

(setpropertyvalue (entlast) "DIST" (command pause))

 

Ive attached the block below. Ive had problems with this before and never really understood a good way to make it work. Thanks in advance for any help.

 

The main program:

 

(DEFUN C:UTIL () (UTIL NIL))
(DEFUN UTIL (TYP)
(GV)
(0V)
(SETVAR 'CLAYER "PLUMBING-EQUIP")
(IF (NULL TYP)
(PROGN (INITGET "Equipment AirConditioner ElectricBox GasStub HoseBib")
(SETQ TYP (COND ((GETKWORD
"\nSpecify Marker [Equipment/AirConditioner/ElectricBox/GasStub/HoseBib] <ElectricBox>: "
)
)
("ElectricBox")
)
)
)
)
(SETQ PNT (GETPOINT "\n\t\t =>> Pick a Location <<= "))
(if PNT
(progn
(vl-cmdf "-INSERT" "UtilityLocator_DYN" PNT "" "" "" "")
(chgdynprop (entlast) "Visibility" TYP)
)
)
(SV)
(PRINC)
)


If you want to use "vl-cmdf" the you must get the attribute value before inserting the block. It requires all elements to be there before it will do anything.

 

If you want to do as the block is inserted then use "command and the while loop to get user input. I have removed the last return ("") from the command "-insert" line, but I don't know how your system is set up so you may need to play around with the number of "" in the command "-insert" line; and if you need a return after the attribute uncomment the (command "")

 

(DEFUN C:UTIL () (UTIL NIL))
(DEFUN UTIL (TYP)
  (GV)
  (0V)
  (SETVAR 'CLAYER "PLUMBING-EQUIP")
  (IF (NULL TYP)
    (PROGN 
      (INITGET "Equipment AirConditioner ElectricBox GasStub HoseBib")
      (SETQ TYP (COND ( (GETKWORD "\nSpecify Marker [Equipment/AirConditioner/ElectricBox/GasStub/HoseBib] <ElectricBox>: "))
                      ("ElectricBox")
                )
      )
    )
  )
  (SETQ PNT (GETPOINT "\n\t\t =>> Pick a Location <<= "))
  (if PNT
    (progn
      ;THIS
      ;(setq txt (getstring "\nEnter Attribute Value : ")) 
      ;(vl-cmdf "-INSERT" "UtilityLocator_DYN" PNT "" "" "" txt)
      ;OR
      (command "-INSERT" "UtilityLocator_DYN" PNT "" "" "")
      (while (= (logand (getvar "cmdactive") 1) 1) (command pause))
      ;(command "")
      (chgdynprop (entlast) "Visibility" TYP)
    )
  )
  (SV)
  (PRINC)
)

 

I am not one of the robots you're looking for

0 Likes
Message 3 of 6

murmanator
Advocate
Advocate

Yeah! Thank you so much. The "THIS" one worked for me. Thanks again!

0 Likes
Message 4 of 6

Sea-Haven
Mentor
Mentor

If you want a dcl for input the attributes you can use my Multi getvals.lsp This can also replace Initget.

 

It can have default values or last entered. Only 1 line of code required can have as many attributes as required.

 

You would enter the values and then run the normal insert command with the variables being added as the getvals makes a list of your replies. Use (nth 0 ans)(nth 1 ans)…….

 

(setq ans (AH:getvalsm (list "Enter Attributes" "Att1" 5 4 "11" "Att2" 8 7 "22" "Att3" 8 7 "33" )))

 

screenshot188.png

0 Likes
Message 5 of 6

murmanator
Advocate
Advocate

Wow, thats really cool, thanks Alan! I got it to work with my program, and I can see how this would come in real handy with multiple attributes. Thanks again!

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

Good to here its for any situation where you need to enter values from a lisp, go to Cadtutor downloads, you will find Multi radio buttons as a replacement for initget, Multi Toggle buttons for multiple choices, and Multigetvals image for multiple input with a image displayed. There all library functions so only need the if not to check if its loaded I have added the loads to mscreenshot183.pngy appload history.

0 Likes