Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
How to align text in this lisp
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: How to align text in this lisp (Read 3371 times)
0 Members and 1 Guest are viewing this topic.
HasanCAD
Swamp Rat
Posts: 1422
How to align text in this lisp
«
on:
December 14, 2019, 05:40:15 AM »
Hi all,
I upgrade LEE lisp to mach my needs
and I want to make change so I want some one to help
Code - Auto/Visual Lisp:
[Select]
;; Layer Legend - Lee Mac
;; Generates a set of lines at a user-specified point and of a given length
;; with associated layer name text sorted alphabetically for every layer in a drawing.
;; https://www.cadtutor.net/forum/topic/64214-legends-lisp/
(
defun
c:LLD
(
)
(
c:LayerLegend
)
)
(
defun
c:LayerLegend
(
/
df i l ln p1 pt sp dsc ent nm lst desc objs
)
(
vl-load-com
)
(
defun
*error*
(
msg
)
(
LM:endundo
(
LM:acdoc
)
)
(
if
(
not
(
wcmatch
(
strcase
msg t
)
"*break,*cancel*,*exit*"
)
)
(
princ
(
strcat
"
\n
Error: "
msg
)
)
)
(
princ
)
)
(
defun
layercount:
assoc
++
(
key lst
/
itm
)
(
if
(
setq
itm
(
assoc
key lst
)
)
(
subst
(
cons
key
(
1+
(
cdr
itm
)
)
)
itm lst
)
(
cons
(
cons
key
1
)
lst
)
)
)
(
if
(
and
(
setq
pt
(
getpoint
"
\n
Specify Point for Legend: "
)
)
(
setq
pt
(
trans
pt
1
0
)
)
(
setq
ln
(
*
100
(
getvar
'TEXTSIZE
)
)
)
(
setq
sp
(
*
2.5
(
getvar
'TEXTSIZE
)
)
)
(
setq
i
-
1
)
)
(
progn
(
vlax-for
blk
(
vla-get-blocks
(
vla-get-activedocument
(
vlax-get-acad-object
)
)
)
(
vlax-for
obj blk
(
setq
lst
(
layercount:
assoc
++
(
vla-get-layer
obj
)
lst
)
)
(
if
(
and
(
=
"AcDbBlockReference"
(
vla-get-objectname
obj
)
)
(
=
:vlax-true
(
vla-get-hasattributes
obj
)
)
)
(
foreach
att
(
vlax-invoke
obj 'getattributes
)
(
setq
lst
(
layercount:
assoc
++
(
vla-get-layer
att
)
lst
)
)
)
)
)
)
(
while
(
setq
df
(
tblnext
"LAYER"
(
null
df
)
)
)
(
if
(
/=
16
(
logand
16
(
cdr
(
assoc
70
df
)
)
)
)
(
setq
l
(
cons
(
cdr
(
assoc
2
df
)
)
l
)
)
)
(
setq
l
(
acad_strlsort l
)
)
)
(
foreach
n l
(
setq
ent
(
vlax
-
ename
->
vla-object
(
tblobjname
"LAYER"
n
)
)
)
(
setq
objs
(
assoc
n lst
)
)
(
setq
objs
(
cdr
objs
)
)
(
setq
dsc
(
vlax-get-property
ent 'Description
)
)
(
setq
nm
(
vlax-get-property
ent 'name
)
)
(
entmakex
(
list
(
cons
0
"LINE"
)
(
cons
8
n
)
(
cons
6
"ByLayer"
)
(
cons
62
256
)
(
cons
10
(
setq
p1
(
polar
pt
(
*
1.5
pi
)
(
*
(
setq
i
(
1+
i
)
)
sp
)
)
)
)
(
cons
11
(
polar
p1
0
. ln
)
)
(
cons
370
-
1
)
)
)
(
entmakex
(
list
(
cons
0
"TEXT"
)
;***
(
cons
1
(
strcat
n
" - Objs: "
(
itoa
objs
)
" - Desc: "
dsc
)
)
;* (the string itself)
(
cons
6
"BYLAYER"
)
; Linetype name
(
cons
7
(
getvar
'TEXTSTYLE
)
)
;* Text style name, defaults to STANDARD, not current
(
cons
8
n
)
; layer
(
cons
10
p1
)
;* First alignment point (in OCS)
(
cons
11
p1
)
;* Second alignment point (in OCS)
(
cons
39
0.0
)
; Thickness (optional; default = 0)
(
cons
40
(
getvar
'TEXTSIZE
)
)
;* Text height
(
cons
41
1.0
)
; Relative X scale factor, Width Factor, defaults to 1.0
(
cons
62
256
)
; color
(
cons
71
0
)
; Text generation flags
(
cons
72
0
)
; Horizontal text justification type
(
cons
73
1
)
; Vertical text justification type
(
cons
210
(
list
0.0
0.0
1.0
)
)
(
cons
370
-
1
)
)
)
)
(
princ
)
)
)
)
Logged
Sorry for my English.
Donate to Theswamp
www.sergiwa.com
ribarm
Gator
Posts: 3298
Marko Ribar, architect
WWW
Re: How to align text in this lisp
«
Reply #1 on:
December 14, 2019, 06:42:11 AM »
You could try to make ACAD_TABLE entity instead... Text inside cells would be aligned as your wish...
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
BIGAL
Swamp Rat
Posts: 1428
40 + years of using Autocad
Re: How to align text in this lisp
«
Reply #2 on:
December 15, 2019, 12:14:40 AM »
If you use mtext a tab is supported, you can add tabs in a string using (chr 9)
(cons 1 (strcat n " - Objs:" (chr 9) (itoa objs) (chr 9) " - Desc: " (chr 9) dsc)) ; not tested
Logged
A man who never made a mistake never made anything
Dlanor
Bull Frog
Posts: 263
Re: How to align text in this lisp
«
Reply #3 on:
December 15, 2019, 06:41:39 AM »
You could change the font to a monospaced eg Lucida Console which would make controlling the length of each sub string easier.
Logged
Dlanor
http://www.theswamp.org/donate.html
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
How to align text in this lisp