Gooey Design

Started by jb, August 09, 2007, 06:56:07 AM

Previous topic - Next topic

jb

So I've been working on a feasibility study for the last couple of weeks using Adobe Indesign CS3 - what a wonderful product.  The software uses these really nice, minimal palettes: the text is small, the buttons are tiny, but it works really well.  If you think about it, once you've learned what buttons do what, a form really doesn't need highly descriptive controls.  Microsoft type forms, including AutoCAD really take up too much space: they really could be made more "minimal".

OK, so after working in CS3 I wanted to create a form for AutoCAD that used the same minimal approach.  This is a quick little "LayerWalk" routine that uses a very minimal OpenDCL modeless form:



So copy the code into VLIDE and check it out:


(vl-load-com)

(if (not (vl-bb-ref 'jbLwalk))
  (vl-bb-set
    'jbLwalk
    (dcl_project_import
      (strcat
"YWt6A8EpAADwQIP7BuKTJqMRZTtu4c2duhP9dG+uKDYeOt6fn9oNgmvZdtczP7wXFORqbizbDECR"
"pxDQQEvPpNQ8nHF+d4/8+nqBfpzdNgJBK0L76dQRA5/TbGzcYcLeXMCipY3QCcPtRMC4EPbH72Ib"
"AOCn5ePnoZLgub/tr5nwxAuMApIqVxfaS3HGTHhu3aEuG0zlsSZHTRGXZ00Tlxccm4ost1wErMiz"
"wic06TNFfbOYGrRONqDOEwNE5TGXlyrslofnDDAxMBnY8yJU4+NXs657uV6wqQCdXE4Hpv1/gP8v"
"2BXAgN/c4SuKdTyhGbOEj+FK8u27hB+pRBZLFBmzeFctveFquQ08oa2fhizDqNbnMJN83xgBVxCZ"
"ayP9dqE+uk5WzHhtzv8uzWH73dFRvHYpS3gzhoGHzLTeEXq6Y8G8rqmmjzV/g7/ewbttx50tXNam"
"9ZC0l1p72UQjg6wvsQmwOmcShrCdlRmq0wU34w0UqAzVbuFVZ4Iqr0EtijFqoxf504/O6U8KxGPK"
"CMWnEiyWRR+7TZIcuS1mBMU1s6OEWBRgF1vt1RH3OoG4HFCcnPBU9SK6G4J8iawwcoOuHMZyq7uk"
"HdHs68wnSVeCw/aceHUylLOjsocDgvY5+qsreMNS3llniuaBqel0/UBubqGqT59Gv95moL9zW0WB"
"nJKiuq7RvBWK3p1a9AAr0Z1eWOubEZ+EQlPeTP3wnBqzHbldfJzFJ74oexLLYVkA1I33E7DQF6LK"
"VRlTGeZHFUeJ9c3Cf8hXGQF4uicwQ/fNegSfEmp4uaem4p3Q7MAu6D1sG4dvpHG0DFZ+G9lcQh/2"
"zIzz2S9LsXNPFzmWgLzdaATfk2RepGT+FiX7IBa1sZY/rkgAotUXvArigbcfVcsNCvumn196g8VG"
"jDMQo7sPAu+mVRrL5N5RML0LaFe5sCCXpo+EBuYw40Z5Zc3CBrHUoqNPKVuojF+JAhB1sd2wXnzt"
"CgIfV88qW6DVsB/ZrFHYjE5b2IyhZFpwgHxlbPDRo+MOxfHF6/Q9wunL+uBWpIio4FxilJNqB3iR"
"Uk5zYekWppD4MExAzicMu2eqQQyTikARGAfrcL4EH6CJZ8yXE8DYOt6gGiEpinn7gPoquF3Lq/gp"
"O9H2Nbrn1eSLNNXwWZAAT2AdQH3nOwHML05c+Df6J2sPEbB0FmH9DMbXeQqTdkavIP/FMMppQuxX"
"fzQ98CU3PZBI/WD7I9SdSqASZEEv5PBCw1fCp3IgFa1NaoRMSgd9Nj3tsa8H4seQPe0lGw+ilaIj"
"jAa9o5mWkax8Sr0PaNV4RR4aj6TQiaDDgq45qZ4d5oGI5q2OvPZ8YiS2zCHEzYAc6sDT8XgFJSE6"
"f7fbLoBNLFZq/KR5DFcOdxRhSs4TWuonWhoogTsQ5WAllmCEEw6DAnGP+Vx1GyhLGiiBm37sc5PF"
"1qW8QK4A+SBWzVRfzQTrPhNd5XuTmnMjeBMBVx6CE83uKFPfssw9GItU/wRYVnO9/0EyDHk0gPnl"
""))))

(defun jb104:GetLayers ( / llist ret)
     (vlax-for x(vla-get-layers(vla-get-ActiveDocument(vlax-get-acad-object)))
       (setq llist(append llist(list(vla-get-name x)))))
  (setq ret(ACAD_STRLSORT llist))
  ret
)
(defun c:jb104_00_OnDocActivated ( /)
  (dcl_ListBox_Clear jb104_00_ListBox)
  (dcl_ListBox_AddList jb104_00_ListBox (jb104:GetLayers))
 
)
(defun c:jb104_00_OnInitialize ( /)    
  (dcl_ListBox_AddList jb104_00_ListBox (jb104:GetLayers))
)

(defun c:jb104_00_cl_OnClicked ( /)
     (dcl_form_close jb104_00)
)

(defun c:jb104_00_thaw_OnClicked ( /)
  (dcl_ListBox_SelItemRange jb104_00_ListBox 0 (dcl_ListBox_GetCount jb104_00_ListBox)0)
  (command "-layer" "_thaw" "*" "")
)

(defun c:jb104_00_on_OnClicked ( /)
  (dcl_ListBox_SelItemRange jb104_00_ListBox 0 (dcl_ListBox_GetCount jb104_00_ListBox)0)
  (command "-layer" "_on" "*" "")
)

(defun c:jb104_00_CheckBox7_OnClicked (nValue /)
     (c:jb104_00_OnDocActivated)
)

(defun c:jb104_00_ref_OnClicked ( /)
     (c:jb104_00_OnDocActivated)
)


(defun c:jb104_00_ListBox_OnSelChanged (nSelection sSelText / rValue layers)
     (Setq rValue (dcl_ListBox_GetSelectedItems jb104_00_ListBox)
   layers(vla-get-layers(vla-get-ActiveDocument(vlax-get-acad-object)))
   Value (dcl_Control_GetValue jb104_00_CheckBox7))
  (if Value
  (foreach x rValue
    (vla-put-layeron(vla-item layers x):vlax-true))
    (foreach x rValue
    (vla-put-layeron(vla-item layers x):vlax-false)))
)

(defun c:jb104_00_CheckBox7_OnClicked (nValue /)
     (dcl_ListBox_SelItemRange jb104_00_ListBox 0 (dcl_ListBox_GetCount jb104_00_ListBox)0)
)

;;; ;
;;; Command Interface ;
;;; ;

(defun c:jbLayerWalk  (/ )
  (defun EnsureProjectLoaded  (project / project-path)
    (if (not (setq project-path (dcl_Project_Load project)))
      (progn
(alert (strcat "ODCL project \"" project "\" failed to load!"))
(exit)
)))
  (EnsureProjectLoaded "jb104")
  (if (not (dcl_Form_IsActive jb104_00))
    (dcl_Form_Show jb104_00))
  (princ))


;;; ;
;;; Floating Form ;
;;; Document Opened ;
;;; ;

(defun jb:Laywalk_IsFloating  (/ )
  (defun EnsureProjectLoaded  (project / project-path)
    (if (not (setq project-path (dcl_Project_Load project)))
      (progn
(alert (strcat "ODCL project \"" project "\" failed to load!"))
(exit)
)))
  (EnsureProjectLoaded "jb104")
  (if (dcl_Form_IsActive jb104_00)
    (c:jb104_00_OnDocActivated))
  (princ))

(jb:Laywalk_IsFloating)
James Buzbee
Managing Memeber
Black Horse Development, LLC

tlindell

That's a really good observation.  Modeless/dockable forms should always make the most of the space they use.  That's been a big pet peeve for me and hope to make many forms like this.  I think you took it to an even higher level than I've attempted, so there's something to strive for :)

I was also trying to figure out how to store and load the dialog code within the defun code today.  Looks like I've found the answer by your example code!

jb

Glad to be of help.  I'm going to start uploading more examples as time allows - so stay tuned!
James Buzbee
Managing Memeber
Black Horse Development, LLC

owenwengerd

Quote from: jb on August 09, 2007, 06:56:07 AM
(if (not (vl-bb-ref 'jbLwalk))
  (vl-bb-set
    'jbLwalk
    (dcl_project_import
      (strcat
   "YWt6A8EpAADwQIP7BuKTJqMRZTtu4c2duhP9dG+uKDYeOt6fn9oNgmvZdtczP7wXFORqbizbDECR"
"pxDQQEvPpNQ8nHF+d4/8+nqBfpzdNgJBK0L76dQRA5/TbGzcYcLeXMCipY3QCcPtRMC4EPbH72Ib"
"AOCn5ePnoZLgub/tr5nwxAuMApIqVxfaS3HGTHhu3aEuG0zlsSZHTRGXZ00Tlxccm4ost1wErMiz"
...

James, I just want to point out that it is no longer necessary to concatenate the strings with (strcat).  The (dcl_project_import) function will accept multiple string arguments and concatenate them itself, thus saving a lot of time and memory consumption over the "(strcat) into one single string" method.
Owen Wengerd (Outside The Box) / ManuSoft

jb

So we just loose the (strcat . . . ) and call


(dcl_project_import
"YWt6A8EpAADwQIP7BuKTJqMRZTtu4c2duhP9dG+uKDYeOt6fn9oNgmvZdtczP7wXFORqbizbDECR"
"pxDQQEvPpNQ8nHF+d4/8+nqBfpzdNgJBK0L76dQRA5/TbGzcYcLeXMCipY3QCcPtRMC4EPbH72Ib"
"AOCn5ePnoZLgub/tr5nwxAuMApIqVxfaS3HGTHhu3aEuG0zlsSZHTRGXZ00Tlxccm4ost1wErMiz"
. . . )


Cool! Thanks Owen.
James Buzbee
Managing Memeber
Black Horse Development, LLC

owenwengerd

Quote from: jb on August 15, 2007, 09:37:16 AM
So we just loose the (strcat . . . ) and call ...

Close. The argument needs to be a list of strings like this:
(dcl_project_import '(
"string1"
"string2"
))

See DistSample2.lsp in the examples folder for a sample.
Owen Wengerd (Outside The Box) / ManuSoft

jb

Even better: so I can just copy and past the OpenDCLForm.LSP contents into the (dcl_Project_import . . .) function!

Thankyou Owen!
James Buzbee
Managing Memeber
Black Horse Development, LLC

tlindell

I didn't get a chance to say this on the sourceforge forums, but I really appreciate being able to do this for distributting purposes rather than relying on a second file like DCL does.

jb

Owen, do we even need the .odcl file?  Can we just use the .lsp file??  If I'm going to wrap it in a VLX or FAS then there in lies the security . . ..
James Buzbee
Managing Memeber
Black Horse Development, LLC

owenwengerd

Quote from: jb on August 19, 2007, 06:47:40 AM
Owen, do we even need the .odcl file?

James, you can use only the .lsp file if you prefer. The only advantage of using an .odcl file is that it's smaller.
Owen Wengerd (Outside The Box) / ManuSoft