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:
dimension polyline with annotation text
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: dimension polyline with annotation text (Read 2568 times)
0 Members and 1 Guest are viewing this topic.
pedroantonio
Guest
dimension polyline with annotation text
«
on:
September 06, 2015, 12:27:13 PM »
Hi. I am trying to convert an old code to work with annotation text but i have some probles with the code.
can any one help ?
Code - Auto/Visual Lisp:
[Select]
(
defun
readableAngle
(
ang
)
(
setq
ang
(
rem
(
+
(
rem
ang
(
*
pi
2.0
)
)
pi pi
)
(
*
pi
2.0
)
)
)
(
if
(
<
(
*
pi
0.5
)
ang
(
*
pi
1.5
)
)
(
+
ang pi
)
ang
)
)
(
defun
c:linedimannot
(
/
e p ht scl len pt ang
)
(
setvar
"cmdecho"
0
)
(
COMMAND
"_layer"
"_m"
"_Diast"
"_c"
"93"
""
"_lw"
"0.30"
""
""
)
(
command
"-style"
"_diast"
"wgsimpl.shx"
"A"
"Y"
"N"
1.75
"1"
"0"
"n"
"n"
"n"
)
(
while
(
>
(
getvar
"cmdactive"
)
0
)
(
command
""
)
)
(
if
(
and
(
setq
e
(
entsel
"
\n
select line or polyline :"
)
)
(
setq
e
(
car
e
)
)
(
member
(
cdr
(
assoc
0
(
entget
e
)
)
)
'
(
"LINE"
"LWPOLYLINE"
"POLYLINE"
)
)
)
(
progn
(
setq
len
(
vlax-curve-getdistatparam
e
(
vlax-curve-getendparam
e
)
)
)
; Get the length of the line/pline to its end.
(
setq
pt
(
vlax-curve-getpointatdist
e
(
/
len
2.0
)
)
)
; Get the point at mid of line/pline.
(
if
(
setq
v
(
vlax-curve-getparamatpoint
e
(
vlax-curve-getclosestpointto
e pt
)
)
)
(
setq
ang
(
angle
'
(
0.0
0.0
0.0
)
(
vlax-curve-getfirstderiv
e v
)
)
)
; Get angle at midpoint.
(
setq
ang
(
angle
(
vlax-curve-getpointatdist
e
(
-
(
/
len
2.0
)
0.01
)
)
(
vlax-curve-getpointatdist
e
(
+
(
/
len
2.0
)
0.01
)
)
)
)
; Get angle at midpoint.
)
(
entmakex
(
list
'
(
0
.
"TEXT"
)
'
(
100
.
"AcDbEntity"
)
'
(
100
.
"AcDbText"
)
'
(
10
0.0
0.0
0.0
)
; The base insert point of the text (ignored when not left aligned).
(
cons
1
(
rtos
len
2
2
)
)
; The length converted to text.
(
cons
50
(
readableAngle ang
)
)
; Rotate the text to follow the line/pline.
'
(
7
.
"_diast"
)
; Text style.
'
(
40
.
1.75
)
'
(
71
.
0
)
'
(
72
.
1
)
(
cons
11
(
polar
pt
(
+
(
/
pi
2
)
(
readableAngle ang
)
)
)
)
; The insert point of the text when not left aligned.
'
(
73
.
2
)
)
)
)
(
princ
"
\n
try again"
)
)
(
princ
)
)
thanks
«
Last Edit: September 07, 2015, 05:03:37 AM by Topographer
»
Logged
roy_043
Water Moccasin
Posts: 1895
BricsCAD 18
Re: dimension polyline with annotation text
«
Reply #1 on:
September 07, 2015, 04:19:31 AM »
In line 39 of the code a closing parenthesis is missing.
Logged
pedroantonio
Guest
Re: dimension polyline with annotation text
«
Reply #2 on:
September 07, 2015, 05:05:07 AM »
I update the code but still not working .Any ideas?
Thanks
Logged
roy_043
Water Moccasin
Posts: 1895
BricsCAD 18
Re: dimension polyline with annotation text
«
Reply #3 on:
September 07, 2015, 07:08:28 AM »
The signature of the polar function is:
Code:
[Select]
(polar pt ang dist)
You are not supplying dist.
Logged
roy_043
Water Moccasin
Posts: 1895
BricsCAD 18
Re: dimension polyline with annotation text
«
Reply #4 on:
September 07, 2015, 07:32:46 AM »
To preempt your next question:
To create annotative text entities you will probably need to switch from the entmake Lisp function to the use of the -TEXT command.
Logged
pedroantonio
Guest
Re: dimension polyline with annotation text
«
Reply #5 on:
September 07, 2015, 09:52:28 AM »
Hi
roy_043
i update the code but the still be not annotated.
An a second qustion. Before change the code i use this command
Code - Auto/Visual Lisp:
[Select]
(
setq
kl
(
*
0.001275
scl
)
; scl = scale kl = the insert text distance from the line
to calculate the insert text distance from the line. Is any option to imput in the code the most use annotate scales in order to calculate the insert distanse ?
Code - Auto/Visual Lisp:
[Select]
(
defun
readableAngle
(
ang
)
(
setq
ang
(
rem
(
+
(
rem
ang
(
*
pi
2.0
)
)
pi pi
)
(
*
pi
2.0
)
)
)
(
if
(
<
(
*
pi
0.5
)
ang
(
*
pi
1.5
)
)
(
+
ang pi
)
ang
)
)
(
defun
c:linedimannot
(
/
e p ht scl len pt ang
)
(
setvar
"cmdecho"
0
)
(
COMMAND
"_layer"
"_m"
"_Diast"
"_c"
"93"
""
"_lw"
"0.30"
""
""
)
(
command
"-style"
"_diast"
"wgsimpl.shx"
"A"
"Y"
"N"
1.75
"1"
"0"
"n"
"n"
"n"
)
(
while
(
>
(
getvar
"cmdactive"
)
0
)
(
command
""
)
)
(
if
(
and
(
setq
e
(
entsel
"
\n
select line or polyline :"
)
)
(
setq
e
(
car
e
)
)
(
member
(
cdr
(
assoc
0
(
entget
e
)
)
)
'
(
"LINE"
"LWPOLYLINE"
"POLYLINE"
)
)
)
(
progn
(
setq
len
(
vlax-curve-getdistatparam
e
(
vlax-curve-getendparam
e
)
)
)
; Get the length of the line/pline to its end.
(
setq
pt
(
vlax-curve-getpointatdist
e
(
/
len
2.0
)
)
)
; Get the point at mid of line/pline.
(
if
(
setq
v
(
vlax-curve-getparamatpoint
e
(
vlax-curve-getclosestpointto
e pt
)
)
)
(
setq
ang
(
angle
'
(
0.0
0.0
0.0
)
(
vlax-curve-getfirstderiv
e v
)
)
)
; Get angle at midpoint.
(
setq
ang
(
angle
(
vlax-curve-getpointatdist
e
(
-
(
/
len
2.0
)
0.01
)
)
(
vlax-curve-getpointatdist
e
(
+
(
/
len
2.0
)
0.01
)
)
)
)
; Get angle at midpoint.
)
(
entmakex
(
list
'
(
0
.
"TEXT"
)
'
(
100
.
"AcDbEntity"
)
'
(
100
.
"AcDbText"
)
'
(
10
0.0
0.0
0.0
)
; The base insert point of the text (ignored when not left aligned).
(
cons
1
(
rtos
len
2
2
)
)
; The length converted to text.
(
cons
50
(
readableAngle ang
)
)
; Rotate the text to follow the line/pline.
'
(
7
.
"_diast"
)
; Text style.
'
(
40
.
1.75
)
'
(
71
.
0
)
'
(
72
.
1
)
(
cons
11
(
polar
pt
(
+
(
/
pi
2
)
(
readableAngle ang
)
)
0.25
)
)
; The insert point of the text when not left aligned.
'
(
73
.
2
)
)
)
)
(
princ
"
\n
try again"
)
)
(
princ
)
)
Thanks
Logged
roy_043
Water Moccasin
Posts: 1895
BricsCAD 18
Re: dimension polyline with annotation text
«
Reply #6 on:
September 07, 2015, 03:49:51 PM »
I don't know a way to get the most frequently used annotative scales. It is possible to get a list of *all* scales that are defined in the drawing. But this would not be very useful for your purpose I think.
I would change the code to use the -TEXT command (as mentioned before) and change the justification of the text to bottom center.
Code - Auto/Visual Lisp:
[Select]
(
defun
ReadableAngle
(
ang
)
(
setq
ang
(
rem
(
+
(
rem
ang
(
*
pi
2.0
)
)
pi pi
)
(
*
pi
2.0
)
)
)
(
if
(
<
(
*
pi
0.5
)
ang
(
*
pi
1.5
)
)
(
+
ang pi
)
ang
)
)
(
defun
Rad_To_Dgr
(
rad
)
(
*
(
/
rad pi
)
180.0
)
)
; Note 1: Only works for the WCS.
; Note 2: The code assumes that AUNITS=0.
; Note 3: Perhaps reset textstyle and clayer?
(
defun
c:LineDimAnnot
(
/
ang en len pt par
)
(
setvar
'cmdecho
0
)
(
command
"_.-layer"
"_make"
"_Diast"
"_color"
93
""
"_lweight"
0.30
""
""
)
(
command
"_.-style"
"_Diast"
"txt.shx"
"_annotative"
"_yes"
"_no"
1.75
1.0
0.0
"_no"
"_no"
"_no"
)
(
if
(
and
(
setq
en
(
car
(
entsel
"
\n
Select line or polyline:"
)
)
)
(
member
(
cdr
(
assoc
0
(
entget
en
)
)
)
'
(
"LINE"
"LWPOLYLINE"
"POLYLINE"
)
)
)
(
progn
(
setq
len
(
vlax-curve-getdistatparam
en
(
vlax-curve-getendparam
en
)
)
)
(
setq
pt
(
vlax-curve-getpointatdist
en
(
/
len
2.0
)
)
)
(
if
(
setq
par
(
vlax-curve-getparamatpoint
en
(
vlax-curve-getclosestpointto
en pt
)
)
)
(
setq
ang
(
angle
'
(
0.0
0.0
0.0
)
(
vlax-curve-getfirstderiv
en par
)
)
)
(
setq
ang
(
angle
pt
(
vlax-curve-getpointatdist
en
(
+
(
/
len
2.0
)
0.01
)
)
)
)
; When is this required?
)
(
command
"_.-text"
"_justify"
"_bc"
"_non"
pt
(
Rad_To_Dgr
(
ReadableAngle ang
)
)
(
rtos
len
2
2
)
)
)
)
(
setvar
'cmdecho
1
)
(
princ
)
)
Logged
pedroantonio
Guest
Re: dimension polyline with annotation text
«
Reply #7 on:
September 08, 2015, 11:16:47 AM »
Hi
roy_043
I test your code and the annotation works but now i have text rotation problem. look the dwg file to see my template settings for units
Logged
roy_043
Water Moccasin
Posts: 1895
BricsCAD 18
Re: dimension polyline with annotation text
«
Reply #8 on:
September 08, 2015, 02:08:44 PM »
Code - Auto/Visual Lisp:
[Select]
(
defun
ReadableAngle
(
ang
)
(
setq
ang
(
rem
(
+
(
rem
ang
(
*
pi
2.0
)
)
pi pi
)
(
*
pi
2.0
)
)
)
(
if
(
<
(
*
pi
0.5
)
ang
(
*
pi
1.5
)
)
(
+
ang pi
)
ang
)
)
; Convert radians to gradians.
(
defun
Rad_To_Grad
(
rad
)
(
*
(
/
rad pi
)
200.0
)
)
; Note 1: Only works for the WCS.
; Note 2: The code assumes that AUNITS=2. ANGBASE and ANGDIR may vary.
; Note 3: Perhaps reset textstyle and clayer?
(
defun
c:LineDimAnnot
(
/
ang en len pt par
)
(
setvar
'cmdecho
0
)
(
command
"_.-layer"
"_make"
"_Diast"
"_color"
93
""
"_lweight"
0.30
""
""
)
(
command
"_.-style"
"_Diast"
"txt.shx"
"_annotative"
"_yes"
"_no"
1.75
1.0
0.0
"_no"
"_no"
"_no"
)
(
if
(
and
(
setq
en
(
car
(
entsel
"
\n
Select line or polyline:"
)
)
)
(
member
(
cdr
(
assoc
0
(
entget
en
)
)
)
'
(
"LINE"
"LWPOLYLINE"
"POLYLINE"
)
)
)
(
progn
(
setq
len
(
vlax-curve-getdistatparam
en
(
vlax-curve-getendparam
en
)
)
)
(
setq
pt
(
vlax-curve-getpointatdist
en
(
/
len
2.0
)
)
)
(
if
(
setq
par
(
vlax-curve-getparamatpoint
en
(
vlax-curve-getclosestpointto
en pt
)
)
)
(
setq
ang
(
angle
'
(
0.0
0.0
0.0
)
(
vlax-curve-getfirstderiv
en par
)
)
)
(
setq
ang
(
angle
pt
(
vlax-curve-getpointatdist
en
(
+
(
/
len
2.0
)
0.01
)
)
)
)
; When is this required?
)
(
setq
ang
(
Rad_To_Grad
(
(
if
(
zerop
(
getvar
'angdir
)
)
+
-
)
(
-
(
ReadableAngle ang
)
(
getvar
'angbase
)
)
)
)
)
(
command
"_.-text"
"_justify"
"_bc"
"_non"
pt ang
(
rtos
len
2
2
)
)
)
)
(
setvar
'cmdecho
1
)
(
princ
)
)
Logged
pedroantonio
Guest
Re: dimension polyline with annotation text
«
Reply #9 on:
September 08, 2015, 05:47:03 PM »
Thank you
roy_043
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
dimension polyline with annotation text