Recent Posts

Pages: 1 [2] 3 4 ... 10
11
AutoLISP (Vanilla / Visual) / Re: Set 'NoPlot' of selected objects' Layers
« Last post by John Kaul (Se7en) on January 15, 2020, 04:43:55 PM »
Here is a list of those AutoLisp layer group codes for your reference.
Code: [Select]
;;
;; LAYER group codes
;;
;; Group codes -   Description
;;
;; 100 - Subclass marker (AcDbLayerTableRecord)
;;
;; 2  -   Layer name
;;
;; 70 - Standard flags (bit-coded values):
;; 1  = Layer is frozen; otherwise layer is thawed
;; 2  = Layer is frozen by default in new viewports
;; 4  = Layer is locked
;; 16 = If set, table entry is externally dependent on an xref
;; 32 = If both this bit and bit 16 are set, the externally
;;      dependent xref has been successfully resolved
;; 64 = If set, the table entry was referenced by at least
;;      one entity in the drawing the last time the drawing
;;      was edited. (This flag is for the benefit of AutoCAD
;;      commands. It can be ignored by most programs that
;;      read DXF files and need not be set by programs that
;;      write DXF files)
;;
;; 62 - Color number (if negative, layer is off)
;;
;; 6 - Linetype name
;;
;; 290 - Plotting flag. If set to 0, do not plot this layer
;;
;; 370 - Lineweight enum value
;;
;; 390 - Hard-pointer ID/handle of PlotStyleName object
;;

Also a fun routine a friend coded up once came to mind (not sure why), so I thought I'd post it just for fun.

Code - Auto/Visual Lisp: [Select]
  1. (defun layerActions (actions layerName / layer laylst flags color plot)
  2.   ;; SMadsen on 06-27-2003
  3.   ;; 0 = no action
  4.   ;; 1 = freeze
  5.   ;; 2 = thaw
  6.   ;; 4 = off
  7.   ;; 8 = on
  8.   ;; 16 = lock
  9.   ;; 32 = unlock
  10.   ;; 64 = plot on
  11.   ;; 128 = plot off
  12.   ;;
  13.   ;; Simply adding the values determines the actions taken by the function. For example:
  14.   ;;
  15.   ;;  (layerActions (+ 8 32 64) "myLayer") will turn on "myLayer", unlock it and enable plotting (I hope).
  16.   (cond ((setq layer (tblobjname "LAYER" layerName))
  17.          (setq laylst (entget layer)
  18.                flags  (cdr (assoc 70 laylst))
  19.                color  (cdr (assoc 62 laylst))
  20.                plot   (cdr (assoc 290 laylst)))
  21.          (cond ((= (logand actions 2) 2) (setq flags (logior flags 1)))
  22.                ((= (logand actions 1) 1) (setq flags (- flags (logand flags 1)))))
  23.          (cond ((= (logand actions 8) 8) (setq color (- (abs color))))
  24.                ((= (logand actions 4) 4) (setq color (abs color))))
  25.          (cond ((= (logand actions 32) 32) (setq flags (logior flags 4)))
  26.                ((= (logand actions 16) 16)(setq flags (- flags (logand flags 4)))))
  27.          (cond ((= (logand actions 64) 64) (setq plot 1))
  28.                ((= (logand actions 128) 128) (setq plot 0)))
  29.          (setq laylst (subst (cons 70 flags)(assoc 70 laylst) laylst)
  30.                laylst (subst (cons 62 color)(assoc 62 laylst) laylst)
  31.                laylst (subst (cons 290 plot)(assoc 290 laylst) laylst))
  32.          (entmod laylst)
  33.          )
  34.         )
  35.   (princ)
  36.   )
12
AutoLISP (Vanilla / Visual) / Re: Old AutoCAD lisp in newer IntelliCAD?
« Last post by ronjonp on January 15, 2020, 04:20:12 PM »
The code errors out for me on the second run ( AutoCAD 2020 ). Don't have intellicad.
Quote
Command: _-block
Enter block name or [?]: TRACKS-2"
Invalid block name.
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.
*Tested in an empty drawing and it works fine...
13
AutoLISP (Vanilla / Visual) / Old AutoCAD lisp in newer IntelliCAD?
« Last post by Jeff_M on January 15, 2020, 02:46:14 PM »
Hey guys, it's been a while since I've posted in here. Someone using IntelliCAD 9.2 found a lisp that I posted back in 2003 for creating a true size set of railroad tracks. It still works fine for me testing in AutoCAD 2020 but he seems to be having an issue where it fails on the third polyline selected. If I were to write this lisp today I would definitely go about it differently, but really have no desire to rewrite it.

So, if anyone here can test in Intellicad and determine why it fails on the third running of it in the same file, I'd appreciate it. Just load the file, run the RRTRAX command, select  a polyline. I believe this was originally written prior to LWPOLYLINE objects, so to update it to work with them it converts those to the old heavy polyline then converts it back when done.

Thanks!
14
AutoLISP (Vanilla / Visual) / Re: Set 'NoPlot' of selected objects' Layers
« Last post by Lee Mac on January 15, 2020, 01:48:58 PM »
FWIW, note that you needn't necessarily stray into Visual LISP & ActiveX to accomplish this - here is an example using Vanilla AutoLISP:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / e x )
  2.     (while (setq e (car (nentsel "\nSelect object whose layer should not be plotted: ")))
  3.         (setq x (entget (tblobjname "layer" (cdr (assoc 8 (entget e))))))
  4.         (entmod (subst '(290 . 0) (assoc 290 x) x))
  5.     )
  6.     (princ)
  7. )
15
CAD General / Re: protected symbol in C3D 2018
« Last post by MP on January 15, 2020, 11:43:20 AM »
Those under NDA who tell: pp slappage

O.o
16
CAD General / Re: protected symbol in C3D 2018
« Last post by rkmcswain on January 15, 2020, 10:30:36 AM »
I don't know what your source is but if it were true, it would be covered by NDA.

Correct.

Those who know, can't tell.
Those who tell, don't know.
17
AutoLISP (Vanilla / Visual) / Re: Set 'NoPlot' of selected objects' Layers
« Last post by keebo on January 15, 2020, 07:13:19 AM »
Perfect! Thank you very much!
18
AutoLISP (Vanilla / Visual) / Re: Set 'NoPlot' of selected objects' Layers
« Last post by Dlanor on January 15, 2020, 07:02:35 AM »
You are correct up until the vla-put-plottable. This has to be enacted of the layer object from the layers collection with the name you've returned with vla-get-layer.

It also needs to be inside the while loop. 

Code - Auto/Visual Lisp: [Select]
  1. (defun c:NoP ( / doc lyrs enm lyr l_obj)
  2.         lyrs (vla-get-layers doc)
  3.   )
  4.   (while (setq enm (car (nentsel)))
  5.     (setq lyr (vla-get-layer (vlax-ename->vla-object enm))
  6.           l_obj (vla-item lyrs lyr)
  7.     )
  8.     (vla-put-Plottable l_obj :vlax-False)
  9.   );end_while
  10.   (princ)
  11. )
  12.  
19
AutoLISP (Vanilla / Visual) / Set 'NoPlot' of selected objects' Layers
« Last post by keebo on January 15, 2020, 05:18:00 AM »
I'm looking to pick objects and have their layers set to no plot.

I dont have a full working understanding of Lisp (or any programming), but I've generally managed to fudge things together based on others hard work and some trial and error.... But not this time!!

More often than not i'll be selecting entities nested within a block/xref, so have been looking at doing it via 
Code: [Select]
(vla-put-Plottable objectLayer :vlax-False)
But this is my first foray in to VLA, and I can't get my head around the object grouping & syntax order.

I've tried lots of variations, so this might not be the 'closest' I've come, but the autocad error isnt really helping me figure things out. Currently I have;

Code: [Select]
(defun c:NoP ( / doc enm obj objLayer)
 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (while (setq enm (car (nentsel)))
   (setq obj (vlax-ename->vla-object enm))
   (setq objLayer (vla-get-layer obj))
 )
 (vla-put-Plottable objLayer :vlax-False)
 (princ)
)

The autocad error returns the correct Layer name, but it's obviously not getting it the way I want it to.

Code: [Select]
Select object:  ; error: bad argument type: VLA-OBJECT "LayerName"
Do I need to look at retrieving a full list of layers at some point?
Is it failing because the Command is set up to get a list of layers, but then I'm processing it as if there's only one? Or am I just way off?

Thanks in advance for any pointers!
20
CAD General / Re: protected symbol in C3D 2018
« Last post by MP on January 14, 2020, 07:07:06 PM »
it will be replaced by VS Code.

Source? Link?

I don't know what your source is but if it were true, it would be covered by NDA.

Indeed.
Pages: 1 [2] 3 4 ... 10