OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: tujn08 on October 03, 2018, 04:06:47 AM

Title: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 03, 2018, 04:06:47 AM
Hi! I just started learning Open DCL and I have problems with palette. Created a palette, loaded it. Now we need to fill in the box list.




(progn
   (setq cmdecho (getvar "CMDECHO"))
   (setvar "CMDECHO" 0)
   (command "_OPENDCL")
   (setvar "CMDECHO" cmdecho)
   (if (dcl-Project-Load "C:\\Users\\USER\\Desktop\\тесты на трассировку\\проект.odcl")
      (progn
         (dcl-Form-Show проект/Property_obj)
         (princ)
            (DEFUN c:Dinfo#OnClicked (/)
               (progn
                  ;(dcl-ListBox-CLEAR boxlist1)
                  :(dcl-Control-SetProperty "проект/Property_obj" "boxlist1" '("13"))
                  :(dcl-Control-SetProperty проект/Property_obj/boxlist1 '("13"))
                  (setq  blk (_GetName iObj))
                  (IF (NOT (WCMATCH blk "`*U*,`*D*,`*X*,`*T*,_*,*|*,A$*"))
                     (SETQ BlkLst (APPEND BlkLst (LIST blk)))
                  )
                  (IF (NULL BlkLst)
                     (dcl-Control-SETVISIBLE проект/boxlist1 T)
                     (dcl-Control-SETVISIBLE проект/boxlist1 nil)
                  )
                  (dcl-ListBox-ADDLIST проект/boxlist1 BlkLst)
                  (PRINC)
               )
            )
           
         (if (= Result 1) (DoSomething))
      )
   )
   (princ)
)
Title: Re: As to the value of Boxlist from the palette and edit
Post by: Fred Tomke on October 03, 2018, 06:34:21 PM
Hi, welcome!
Without knowing your project in detail, I'd say, that everything is fine but the last line.
(if (= Result 1) (DoSomething))

Against modal forms, the program will not stop at dcl-form-show in modeless forms and palettes.
So you need some events to catch ButtonClick or ListSelectionChanged.

I recommend you to have a closer look to the tutorial and the samples.
Regards, Fred
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 03, 2018, 09:27:09 PM
this code is almost all of the example. In the opendcl examples, there is no explicit example for the palette - only visual design. Maybe there are other examples or ready-made solutions in the palette? The task is simple for me right now: select an object and show and change its properties in the palette (I mean extended data).
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 03, 2018, 09:32:12 PM
Here is a project-please show me how to use "dsl-Control-SetProperty" and "dll-Control-GetProperty" - by putting them in "boxlist1" .For example, a simple list '("1" "2" "3")
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 03, 2018, 10:10:20 PM
(dcl-Control-GetProperties проект/Property_obj/boxlist1)
I figured out seems to me to be able...

(dcl-Control-SetProperty проект/Property_obj/boxlist1 "List" '("1" "2"))
Title: Re: As to the value of Boxlist from the palette and edit
Post by: roy_043 on October 04, 2018, 12:44:50 AM
You can use the Control Browser to find the properties and methods that are available for a control.
(dcl-Control-SetList проект/Property_obj/boxlist1 NewValue [as List of Strings])
Looking at the ComboBoxLab.lsp sample may be helpful as well.
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 04, 2018, 12:48:50 AM
I figured it out.
(progn ; распечататься все значения свойств объекта
(setq lst_sampl (dcl-Control-GetProperties проект/Property_obj/obj))
(foreach x lst_sampl
(terpri)
(princ (dcl-Control-GetProperty проект/Property_obj/obj x))
(princ "___")
(princ x)
)
)


Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 04, 2018, 12:51:06 AM
"проект/Property_obj/obj" - how can this be written to a variable?
(set f (read (strcat "проект/Property_obj/obj")))  -in this case, it does not work
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 04, 2018, 02:16:44 AM
how to intercept the selected primitive? In the same way as the properties palette
Title: Re: As to the value of Boxlist from the palette and edit
Post by: Fred Tomke on October 04, 2018, 03:52:15 AM
Hi,

Quote"проект/Property_obj/obj" - how can this be written to a variable?

I should mention that there are two ways to call controls:
1. Using the automatically defined variable when a project or form is loaded.
(dcl-Control-GetProperty project/form/control "Visible")

2. Using keywords as string
(dcl-Control-GetProperty "project" "form" "control" "Visible")

You can override the variable name when you set a value into the (VarName) property of a selected control in the property pane.
You can get the symbol-value by calling (vl-symbol-value (read "project/form/control")) or (vl-symbol-value (read 'project/form/control))
You can get all properties of a form or control using (mapcar '(lambda (x) (cons x (dcl-control-getproperty project/form/control x))) (dcl-control-getproperties project/form/control))

Hope that helps,
Fred
Title: Re: As to the value of Boxlist from the palette and edit
Post by: Fred Tomke on October 04, 2018, 04:57:13 AM
Hello,

Quote from: tujn08 on October 03, 2018, 09:27:09 PM
this code is almost all of the example. In the opendcl examples, there is no explicit example for the palette - only visual design. Maybe there are other examples or ready-made solutions in the palette? The task is simple for me right now: select an object and show and change its properties in the palette (I mean extended data).

when I understood it in the right way you want to get noticed when an object gets selected in the current space to display/modify xdata of an entity.
Then I'd prefer a grid or listview instead of a listbox. When I had built OpenDCL projects in the past I never used listbox because I always needed much mor information.

There are only a few things different between model and non-modal forms (modeless form, toolbar, palette):
In palettes...

I cannot go more into detail as long I do not know where you need help.
Regards, Fred

Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 04, 2018, 10:06:01 PM
so. the first answer is very useful. and with the second not know that to do. I am sure that I am doing something wrong, but the form starts and the program works - it satisfies me.

I want to achieve a certain SPDS-without proxy-graphics.That is: clicked on the object (without calling functions) and in the palette got properties that can be changed.
While I do not know how - trying to implement as Lee Mac. http://www.lee-mac.com/dinfo.html (http://www.lee-mac.com/dinfo.html)

I change the circle to a square, point to the object-get the properties.
(progn
(setq
prn 'Coordinates
prn1 'InsertionPoint
prn2 'Layer
ofg 0.0 ; сдвиг оси
ofv 0.0 ; сдвиг оси
x T
lyr "слой_АК"
rect nil
)
(while x
(progn
(setq gr (grread t 15 0) ; получение координат
gr2 (cadr gr) ; Y
gr1 (car  gr) ; X
code (car gr) ; X
data (cadr gr) ; Y
vs (/ (getvar 'VIEWSIZE) 100) ; масштаб окна
r 0.5

)
; (command "_rectang" (list X1 Y1 0) (list X2 Y2 0))
)
(setq
X (nth 0 data)
Y (nth 1 data)
X1 (- X (* vs r))
Y1 (- Y (* vs r))
X2 (+ X (* vs r))
Y2 (+ Y (* vs r))

)
(if rect
(progn)
(progn
(command "_rectang" (list X1 Y1 0) (list X2 Y2 0))
(setq
rect (vlax-ename->vla-object (entlast))
crd (vlax-get rect prn)
)
(vlax-put rect "color" 1)
)
)
(cond
( (= 3 gr1) ; команды от мыши
(setq x nil)
(vla-delete rect)
)
( (or (= 5 gr1) (= 3 gr1))
(setq
pt1 (nth 0 gr2) ; координаты курсота X
pt2 (nth 1 gr2) ; координаты курсота Y (vlax-curve-getclosestpointto ent pt2)
)
; (setq n_pt (list (+ pt1 ofg) (+ pt2 ofv) 0.0)) ; точка курсора
; (setq cord (vlax-curve-getClosestPointTo vla_line n_pt nil))
(setq crd
(list
X1 Y1 X2 Y1 X2 Y2 X1 Y2
)
)
(vlax-put rect prn crd)
)
( (= 2 gr1) ; команды от клавиатуры
(cond
( (member gr2 '(013 032 069 101 32 69 13)) ; (chr 003) "\003" (chr 032)" " (chr 069)"E" (chr 101)"e"
(setq x nil) ; выход из цикла
; (*error* nil) ; прерывание
; (princ gr2)(terpri)
(terpri)(terpri)
(vla-delete rect)
)
)
)
)

)
)


In the properties and record their data from the database or by yourself.

(progn
(vl-load-com)
(setq a (vlax-ename->vla-object(car (entsel "выбрать")))) ; выбрали объект и превратили в vla
(vlax-ldata-put a "связь" '("с прибором КХ1")) ; записали в объект данные
(vlax-ldata-put "RISE_pr" "пересечения" '("с линией 4654")) ; создали словарь с именем пересечения и данными ()
(vlax-ldata-get "RISE_pr" "связь") ; прочитать значение из словаря RISE_pr под именем связь

(vlax-ldata-list "RISE_pr") ; весь список данных в словаре
(vlax-ldata-delete "RISE_pr" "связь") ; удаляет данные с именем
)


In the properties and record their data from the database or by yourself. From closest, that is similar : http://ventsoft.ru/content/magicad-eliektrosnabzhieniie (http://ventsoft.ru/content/magicad-eliektrosnabzhieniie) or EPLAN.

I want to build a track, arrange the equipment as a result of getting the length, quantity, schemes and reports, as well as simultaneously select the cable channel and other equipment.

A big problem in 2D and 3D . Expect to work in 2D.
Why:
-not everyone knows how to work in 3D-can not be trained. 
-Eventually need a 2D plan.
-3D plan is not always possible to perform-say an existing oil plant, where it is necessary to pave the track.
- No 3D database equipment and no one wants to create it

in General 2D is easier for designers today. I judge only by small companies. Large companies can also buy EPLAN
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 04, 2018, 10:10:16 PM
Here are my test attempts:
https://www.youtube.com/channel/UClvU-jcsbJ1DS3bNqJx65XQ (https://www.youtube.com/channel/UClvU-jcsbJ1DS3bNqJx65XQ)
And thanks for the answers!
Title: Re: As to the value of Boxlist from the palette and edit
Post by: Fred Tomke on October 04, 2018, 11:14:50 PM
Hello,

the desired task is well-known to me. I built some construction and analyzing tools for a long-term partner who is developing and supporting lightning/illumination planning for ships for transportation. Meanwhile all the construction is done in AutoCAD and all the management is done in a webframe based on MySQL. All the equipment (switches, lamps, sleeves, conductors, ducts) is managed by team A, team B is construction in AutoCAD using the allowed equipment for the certain project and team A and C can summarize and analyze the network, creating reports and offers. Team A and C need no AutoCAD.

At my day job I'm an AE supporting and consulting energy providers to document and visualize the networks of gas, water, waste water, heating and electricity. For that we're using AutoCAD Map 3D and its former TOPOBASE technology. All the stuff is stored in an Oracle or MS SQL Database. It is completey drawn in 2D (in opposite to the first sample).

Just wanted to mention, that it is known to me.
For your desires, I recommend you to build a palette with a grid or a listview, but grid seems to be much more comfortable to the customer.
Whenever an element is selected you can read the properties and fill the grid with the data you stored.

Your challange would be to get noticed by LISP that selection has changed or your mouse is moving over a an element.
That's why I'd consider it a two "projects": (1) visualizing and managing data in the palette and (2) getting the selected element.
Because for (2) there are different ways to achieve this, I'd place a simple button on the palette to select an element in the drawing to fill the grid.

Once that works, we can think about alternatives to the button.
Hope that is a vision you can deal with.

Regards, Fred
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 05, 2018, 12:28:25 AM
Yes, "button" is implemented. The truth is not in this code. This code scans objects under the cursor-with no explicit selection. Also useful to me. And in (defun _Display) where (princ (vlax-get vla_line pro 3)) - just will fill the palette.

(defun q (/)
(defun _Display (ss / vla_line)
(cond
((or (not ss) (= (sslength ss) 0))
(if en_line (progn (redraw en_line 4) (setq en_line nil)))
)
((> (sslength ss) 0)
(setq en_line (ssname ss 0) vla_line (vlax-ename->vla-object en_line))
(redraw en_line 3)
(if (eq en_line en_x)
  (progn)
(progn (princ (vlax-get vla_line prn3)) (terpri))
)
(setq en_x en_line)
)
)
)
(setq
prn 'Coordinates
prn1 'InsertionPoint
prn2 'Layer
prn3 'Length
x T
lyr "слой_АК"
rect nil
ss nil
)
(while x
(setq gr (grread t 15 0) ; получение координат
gr2 (cadr gr)
code (car gr) ; X
data (cadr gr) ; Y
vs (/ (getvar 'VIEWSIZE) 100) ; масштаб окна
r 0.5
X (nth 0 data)
Y (nth 1 data)
X1 (- X (* vs r))
Y1 (- Y (* vs r))
X2 (+ X (* vs r))
Y2 (+ Y (* vs r))
)
(if rect
(progn)
(progn
(command "_rectang" (list X1 Y1 0) (list X2 Y2 0))
(setq
rect (vlax-ename->vla-object (entlast))
crd (vlax-get rect prn)
)
(vlax-put rect "color" 1)
)
)
(cond
( (= 3 code) ; команды от мыши
(setq x nil)
(vla-delete rect)
(if en_line (progn (redraw en_line 4) (setq en_line nil)) )
)
( (or (= 5 code) (= 3 code))
; (setq n_pt (list (+ pt1 ofg) (+ pt2 ofv) 0.0)) ; точка курсора
; (setq cord (vlax-curve-getClosestPointTo vla_line n_pt nil))
(setq crd (list X1 Y1 X2 Y1 X2 Y2 X1 Y2) pt1 (list (nth 0 crd) (nth 1 crd)) pt2 (list (nth 4 crd) (nth 5 crd)))
(vlax-put rect prn crd)
(if (setq ss (ssget "_C" pt1 pt2 (list (cons 0 "lwpolyline") (cons 8 lyr))))
(progn
(ssdel (vlax-vla-object->ename rect) ss)
(_Display ss)
  (setq ss nil)

)
(if en_line (progn (redraw en_line 4) (setq en_line nil)))
)
)
( (= 2 code) ; команды от клавиатуры
(cond
((member code '(013 032 069 101 32 69 13)) ; (chr 003) "\003" (chr 032)" " (chr 069)"E" (chr 101)"e"
(setq x nil) ; выход из цикла
(vla-delete rect)
(if en_line (progn (redraw en_line 4) (setq en_line nil)) )
)
)
)
)
)
)


I work in a CAD Department, a small firm. I'm trying to get engineers to give me a task to develop a program (visual and practical interaction). To make can't - saying it's impossible - just that they are lazy. I have already worked out the search for connections between the equipment, right now I want to write a new version correcting the shortcomings of the previous one. We do not have so many specialists that would fill the database - even the engineers themselves will not do it, though they need such a program. Lazy - what can I add.
Title: Re: As to the value of Boxlist from the palette and edit
Post by: Fred Tomke on October 05, 2018, 04:04:17 AM
Hi, I have some stomach ache with the multiple command "_rectangle".
I recommend you to create a polyline just before running while loop and just change the coordinates during while loop. Maybe its much mor performant.
Regards, Fred
Title: Re: As to the value of Boxlist from the palette and edit
Post by: Fred Tomke on October 05, 2018, 04:05:42 AM
... and reduce the amount of calling command. You won't have fun with it in a palette in my experiences.
Regards, Fred
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on October 17, 2018, 05:51:40 AM
Hi! I was busy

1.
Quote from: Fred Tomke on October 05, 2018, 04:05:42 AM
... and reduce the amount of calling command. You won't have fun with it in a palette in my experiences.
Regards, Fred
- about this I do not understand

2. with square Yes - it is possible for a series make, but it is not drawn if drawn in a loop.
Title: Re: As to the value of Boxlist from the palette and edit
Post by: tujn08 on December 07, 2018, 10:08:56 AM
Hi! I've returned.

Really need method: chose a primitive is received the properties (of course: from the dictionary inside the primitive). Can this be implemented without resorting to an additional button "select"?