Autolisp Code to run on startup help

Autolisp Code to run on startup help

Anonymous
Not applicable
1,059 Views
7 Replies
Message 1 of 8

Autolisp Code to run on startup help

Anonymous
Not applicable

Hello all.

 

Wondering if I can get some help with some autolisp code.

 

I would like the following to run on startup to limit users ability to modify and play with things they have been told not to! wondering if some of the experts in lisp programming could give it a quick look and highlight where I might be going wrong. it will be used on autocad 2019

 

the code is as follows:-

 

(defun S::STARTUP ()
(command
"undefine"
"refedit")
 ;undefine the Refedit command
(setvar "blockeditlock" 1)
 ; set blockeditlock variable to 1
(command
"undefine"
"blockeditlock")
;undefine blockedit lock command
(command
"undefine"
"explode")
 ;undefine the Explode command
(defun C:explode ( / lst1 en typ)
 :After undefining the explode command we would then redefine it
 
   (setq lst1 (list “07 REDUCER CONCENTRIC (left)” “07 REDUCER ECCENTRIC (left)” “10 REGULATOR BACK PRESS.” “10 REGULATOR BACK PRESS. (EX.TAP)” “10 REGULATOR PRESS. REDUCING” “10 REGULATOR PRESS. REDUCING (EX.TAP)” “A1BORDER” “ACT1” “ACT2” “ACT3” “ACT4” “ACT5” “AIR SEPARATOR” “ARROW” “ARROW-LARGE” “ARROW-SMALL” “BD1” “BD2” “BELLOWS” “BFV” “BREAK” “BYPASS VALVE” “CAP” “CAP - FILLET WELD” “CAP - QUICK RELEASE” “CAP SCREWED” “CHEMSEAL” “CLIENT APPROVAL” “CN BOUNDRY” “COALESCING FILTER” “DELUGE CONTROL VALVE” “DIFFERENTIAL PRESSURE REGULATOR” “DIVIDEBOX” “DOUBLE VANE DAMPER” “DRIVE” “DRIVE-GEAR” “DRIVE-TURBINE” “DRY BREAK” “DRY TANKER COUPLING” “EARTHBAR” “EJECTOR” “ELECTRIC HEATER” “EQUIP-TAG” “EXPJOINT” “FALL” “FAN-BLOWER” “FILTER” “FILTER REGULATOR” “FILTER-DUPLEX” “FLAG CONTINUE” “FLAG LH” “FLAG RH” “FLAMEARRESTOR” “FLANGE” “FLOPITOT” “FLOPOSD” “FLOTURBINE” “FLOVA” “FSG1” “FT” “FX” “G207” “GATE BYPASS VALVE” “GOGGLE VALVE” “HATCH-PRESSURE” “HEATEX-SPIRAL” “HOSE CON” “HOSE CON – CAP” “HX1” “INLINE” “INTERLOCK” “IPSV01N” “IPSV01N-INLINE” “LESSTHAN” “LINE SPEC CHANGE HORZ” “LINE SPEC CHANGE VERT” “LINETAG” “MIN FLOW” “MKV1” “MKV2” “MULTBOX” “MULTI VANE DAMPER” “NOZZLE” “NOZZLEMTR” “NOZZLE-VESSEL” “ORIFICE” “ORIFICE PLATE FLOW SENSOR” “ORIFICE PLATE NO SENSOR” “PARALLEL SLIDE VALVE” “PIPE BREAK” “PLATE HEAT EXCHANGER” “PLITE” “PLUG – SCREWED” “PRESSURE REDUCING VALVE” “PRVEXPCHAM” “PSV PILOT” “PSV TWIN EXHAUST” “PUMP-CENT” “PUMP-DIAPH” “PUMP-GEAR” “PUMP-GENERAL” “PUMP-HELROTOR” “PUMP-LIQJET” “PUMP-POSITIVE” “PUMP-RECIP” “PUMP-SCREW” “PURGELH” “PURGERH” “REGULATOR SPRING DIAPHRAM” “REVMARKER” “R-SPOOL” “SDNRV” “SEPARATOR” “SIDEENTRY” “SIGNAL CONTINUATION” “SILENCER” “SINGLE VANE DAMPER” “SINGLEFLOPITOT” “SLAM SHUT” “SLIDING PLATE VALVE” “SMALLT” “SPADE (CLOSED)” “SPADE (OPEN)” “SPECBLIND-NORMCLOSED” “SPECBLIND-NORMOPEN” “SPRAY” “SPRAYBALL” “STEAM-TRAP” “STRAINER-Y” “SWING SPEC BLIND” “TAG1” “TAG2” “TAG3” “TAG4” “TAGDASH” “THERMAL EXPAN COMP” “THERMAL EXPAN COMP – BLADDER” “TP” “TUNDISH 3” “TUNDISH-1” “TUNDISH-2” “ULT” “V01” “V01 INST” “V02” “V03” “V04A” “V04B” “V05” “V05 INST BALL” “V05 LOCK” “V06” “V07” “V08” “V09” “V11” “V12” “V13” “V14” “V143” “VBFLY” “V-CONE METER” “VENT-COWL” “VENT-OPEN” “VENTURI” “VGLOBE” “VNEEDLE”))
   ;list of block names that must NOT be exploded

   (setq en (car (entsel "\n Select block reference, polyline, dimension,
      or mesh: ")))
   ;gets the block and mimics the explode prompt
 
   (setq typ (entget en))
   ;get the entity data
 
   (setq typ (cdr (assoc 2 typ)))
   ;get the block name
 
   (if (member typ lst1)
       ;if the selected block name is a member of our list
 
         (alert "\nThis Block Cannot be Exploded.
                 \n    Refer to System Manager")
         ;inform the user
     
         ;if it is not
         (progn
         ;do the following
 
         (command ^c^c)
         ;cancel any commands
 
         (command ".EXPLODE" en)
         ;explode the block
 
      );progn
 
   )
   ;if
 
(princ)
;finish clean
 
);defun
(princ)
;load clean
 
 
Many thanks in advance!!
0 Likes
1,060 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

The EXPLODE is so complex and powerful command and you have guts to replace that with something that poor?! 

Message 3 of 8

doaiena
Collaborator
Collaborator

Redefining commands should be avoided unless some very special circumstances arise. In your case though, if you don't want users to explode these blocks, why don't you just set the "Allow exploding" property to "No"?

0 Likes
Message 4 of 8

Anonymous
Not applicable

While I agree that the explode command is all powerful and complex it is like a gun! Perfectly safe in the correct hands it can be lethal in the wrong hands! Unfortunately despite all my attempts to get certain users to follow protocol, I would rather just remove the gun from there hands all together and replace it with a plastic replica. Despite setting explode blocks to no these users just edit the block instead. Hence the code to undefine refedit and set blockeditlock to on. This is a special circumstance where normally I wouldnt even consider this, but the damage caused by having to repair drawings is taking too much time. 

0 Likes
Message 5 of 8

dlanorh
Advisor
Advisor

It is pointless undefining core commands, as these are still available by preceeding the command name with a dot eg

.explode. A better solution would be a reactor to intercept the commands, display a message and log the event.

 

An even better solution would be to fire the first person that doesn't comply with company policy, but then I'm just a total b'stard.👿 😉

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

0 Likes
Message 6 of 8

Anonymous
Not applicable

Admittedly your "better solution" would be my more favorable as well. Sadly I don't have the authority to. The intercept and log idea sounds great to me, at least then I can track what's been done and keep a record. I assume this can be done with the refedit and explode commands? 

0 Likes
Message 7 of 8

dlanorh
Advisor
Advisor

It can be done with EXPLODE See Here 

 

but I don't know about REFEDIT. My knowledge of reactors amounts to knowing they exist.

 

But again these will only intercept command line calls. IIRC an explode would still be possible using the vla-explode method in a lisp.

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

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

1st up spying on people can have some serious consequences, I have used a command logger program it logs every command used plus lots of other info, how many times the user erases etc, meaning are they doing it worng erasing and doing again, other thing it logs time, so does how many commands = productivity.

 

Nice thing can set up to log just one user, you can check a users name (getenv "userprofile") then say load the program. Set the output report not to users pc.

 

 

 

 

0 Likes