OpenDCL Picturebox

OpenDCL Picturebox

DGCSCAD
Collaborator Collaborator
1,192 Views
14 Replies
Message 1 of 15

OpenDCL Picturebox

DGCSCAD
Collaborator
Collaborator

I'm just getting into ODCL and trying a simple picture dialog. Not sure why this code won't show the pic. It's in my support path, and even if I hard code the path it won't load.

The Error is:

Error: NIL value not allowed.

Function: dcl-PictureBox-LoadPictureFile

Argument 0

(defun c:ODCT ()
(command "_OPENDCL")
(dcl_project_load "ODCL-Test-001" T)
(dcl_form_show ODCL-Test-001_Form1)
(dcl-PictureBox-LoadPictureFile ODCL-Test-001/Form1/PictureBox1 "ge_logo3.png" T)
(princ)
)

 

 

AutoCad 2018 (full)
Win 11 Pro
0 Likes
1,193 Views
14 Replies
Replies (14)
Message 2 of 15

CodeDing
Mentor
Mentor

@DGCSCAD ,

 

Just tested your exact setup on my end.

Update these lines:


 

(dcl_form_show ODCL-Test-001_Form1)
(dcl-PictureBox-LoadPictureFile ODCL-Test-001/Form1/PictureBox1 "ge_logo3.png" T)

 

 

...To These:

 

(dcl-Form-Show ODCL-Test-001_Form1/Form1)
(dcl-PictureBox-LoadPictureFile ODCL-Test-001_Form1/Form1/PictureBox1 "ge_logo3.png" T)

 

 

Edit:

Also, please Double-Check the exact name of your .odcl file. Mine originally had " ... _Form1" in the name.

Be sure to use your Control Browser to double-check these naming conventions (just right-click on the entity to open Control Browser for it).

 

Best,

~DD


0 Likes
Message 3 of 15

DGCSCAD
Collaborator
Collaborator

I appreciate the reply and help, but it's still not showing the pic. With my original code the box pops up but it's blank and the error comes after closing it out.

 

Is there a sample dcl-PictureBox-LoadPictureFile (that works) somewhere I could take a look at? I can't seem to find anything on that.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 4 of 15

CodeDing
Mentor
Mentor

I'm sure a simple mistake is happening somewhere. You just need to double-check everything in your code.

Did you try the Control Browser?

Let's do this, fill in this code by only copying/pasting values. No typing.

 

(defun c:ODCT ( / imageName fileName formName pictureBoxName)
  (command "_OPENDCL")

  ;; Here's your image file name:
  (setq imageName "ge_logo3.png")

  ;; Paste your odcl File name below. Be sure to leave the quotes around it!
  (setq fileName "[paste your odcl file name here]")

  ;; Paste your Form name below.
  ;; Right-click your form in the editor window -> Control Browser -> "Show" method -> copy your form name from inside "syntax" area
  ;; Do NOT place it in quotes.
  ;; Should look something like: ODCL-Test-001_Form1
  (setq formName [paste your form name here])

  ;; Paste your PictureBox name below.
  ;; Right-click your picture box in the editor window -> Control Browser -> "LoadPictureFile" method -> copy your form name from inside "syntax" area
  ;; Do NOT place it in quotes.
  ;; Should look something like: ODCL-Test-001_Form1/Form1/PictureBox1 or ODCL-Test-001/Form1/PictureBox1
  (setq pictureBoxName [paste your picturebox name here])

  (cond
    ((not (findfile imageName)) (alert (princ "\nThe Image for your project could not be found.")))
    ((not (findfile fileName)) (alert (princ "\nYour ODCL project file could not be found.")))
    (t
      (dcl_Project_Load fileName T)
      (dcl-Form-Show formName)
      (dcl-PictureBox-LoadPictureFile pictureBoxName imageName T)
    )
  )
  (prompt "\nCommand Complete.")
  (princ)
)

 

 

Best,

~DD

0 Likes
Message 5 of 15

DGCSCAD
Collaborator
Collaborator

With copy/pasting the syntax variables to your code, I get:

 

"Your ODCL project file could not be found."

 

With copy/pasting the same variables to my original code I get the same previous error after closing the empty dialog.

Still no show piccy.

 

What gives, ODCL? lol

 

I noticed my system slowing considerably after installing it, then today it was sludge, so I uninstalled it and everything is fine again. *shrug* Not sure whats going on with that. I'll check everything on a different system tomorrow.

 

I appreciate the help CodeDing.

 

For science purposes, here's my specs:

Windows 10 Home 64-bit

.NET v4.8 Full

AMD Ryzen Threadripper 2950X 16-Core

NVIDIA GeForce RTX 2080 Ti

32MB RAM

AutoCAD 2022 (vanilla)

 

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 6 of 15

CodeDing
Mentor
Mentor

@DGCSCAD wrote:

With copy/pasting the syntax variables to your code, I get:

"Your ODCL project file could not be found."


Wooo! That's progress! this means AutoCAD isn't finding your project file, so if you ever get it installed again, use my code and approach again and instead of only using your file name, "myODCLfile.odcl", you should use the full path to that file instead:

"c:\\users\\me\\desktop\\myODCLfile.odcl"

 

That should work!

Best,

~DD

0 Likes
Message 7 of 15

DGCSCAD
Collaborator
Collaborator

Ok, from a different system I created a simple test. Still getting the original empty pic box and error after closing. This should work but it doesn't.

Code:

(defun c:ODCT ()
(command "_OPENDCL")
(dcl_Project_Load "ODCT.ODCL" T)
(dcl-Form-Show ODCT/Form1)
(dcl-PictureBox-LoadPictureFile ODCT/Form1/PictureBox1 "TestLogo" T)
)

 Result:

Error4.PNG

 

Error after closing:

Error1.PNG

 

Syntax:

Error2.PNGError3.PNG

AutoCad 2018 (full)
Win 11 Pro
Message 8 of 15

CodeDing
Mentor
Mentor

Did you see my previous message? You should be using the full path to your odcl project file. It seems you are focused on the error message and believe something is wrong with the picture box itself, but I am under the impression that the picture box is failing because there is no project loaded for the picture box to populated into. We cannot focus on fixing one part of our codee because we THINK that's where the problem is, we need to step back and look at the ENTIRE code because something may be wrong elsewhere. That's why I wrote a code which checked the other aspects of your project, and it helped us identify that we should be providing the full path to the project file.

 

Best,

~DD

0 Likes
Message 9 of 15

CodeDing
Mentor
Mentor

@DGCSCAD wrote:

 

(defun c:ODCT ()
(command "_OPENDCL")
(dcl_Project_Load "ODCT.ODCL" T)
(dcl-Form-Show ODCT/Form1)
(dcl-PictureBox-LoadPictureFile ODCT/Form1/PictureBox1 "TestLogo" T)
)

 


I think you're REAL close, but looking at your code, it appears that your image file has no extension. This may be your hang up this time.

 

I would recommend always checking for files that we assume are being loaded:

 

(defun c:ODCT ( / fileName imgName)
  (command "_OPENDCL")
  (setq fileName "ODCT.ODCL")
  (setq imgName "TestLogo.png")
  (cond
    ((not (findfile fileName)) (alert (princ "\nProject File not found.")))
    ((not (findfile imgName)) (alert (princ "\nImage File not found.")))
    (t
      (dcl_Project_Load fileName T)
      (dcl-Form-Show ODCT/Form1)
      (dcl-PictureBox-LoadPictureFile ODCT/Form1/PictureBox1 imgName T)
    )
  )
  (prompt "\nODCT Complete.")
  (princ)
)

 

 

Best,

~DD

0 Likes
Message 10 of 15

DGCSCAD
Collaborator
Collaborator

D'oh! In my haste I forgot to add the the extension back after trying every possibility to find where it's going wrong.

 

I ran your code above and got the same result as in my previous post, an empty picture box and an error after closing.

 

I also tried using the full path for the project ODCL file and got the same result.

AutoCad 2018 (full)
Win 11 Pro
Message 11 of 15

DGCSCAD
Collaborator
Collaborator

This gets the same results:

 

(defun c:ODCT ( / fileName imgName)
  (command "_OPENDCL")
  (setq fileName "C:\\PRD\\Apps\\LISP\\ODCT.ODCL")
  (setq imgName "C:\\PRD\\Apps\\LISP\\TestLogo.png")
  (cond
    ((not (findfile fileName)) (alert (princ "\nProject File not found.")))
    ((not (findfile imgName)) (alert (princ "\nImage File not found.")))
    (t
      (dcl_Project_Load fileName T)
      (dcl-Form-Show ODCT/Form1)
      (dcl-PictureBox-LoadPictureFile ODCT/Form1/PictureBox1 imgName T)
    )
  )
  (prompt "\nODCT Complete.")
  (princ)
)
AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 12 of 15

CodeDing
Mentor
Mentor

@DGCSCAD wrote:

This gets the same results:


💣💥💫😵

 

Idk what else to try then. I'm doing everything you're doing and do not get the error when everything is setup properly.

I have tried in Civil 3D 2021 & 2023 (merely AutoCAD + add-ons).

I use this code:

(defun c:ODCT ( / fileName imgName)
  (command "_OPENDCL")
  (setq fileName "[.....]\\LISP\\odcl\\Test-Project.odcl")
  (setq imgName "[.....]\\Pictures\\Clip Art\\manhole_san_sewer.png")
  (cond
    ((not (findfile fileName)) (alert (princ "\nProject File not found.")))
    ((not (findfile imgName)) (alert (princ "\nImage File not found.")))
    (t
      (dcl_Project_Load fileName T)
      (dcl-Form-Show Test-Project/Form1)
      (dcl-PictureBox-LoadPictureFile Test-Project/Form1/PictureBox1 imgName T)
    )
  )
  (prompt "\nODCT Complete.")
  (princ)
)

 

And get this form:

image.png

 

The only hurdle I ran into was when I tried running oDCL on 2023. I had to research how to load the ARX file(s), but it wouldn't let me even show the form or get an error message until I resolved that, so your AutoCAD is obviously loading the oDCL files correctly.

 

Since you're running 2022, I don't believe this is a versioning issue because I ran on both '21 and '23 and got the same good result. I'm out of ideas, sorry I can't help more. Hopefully someone else can chime in soon.

 

My Specs:

Windows 10 Pro

64 bit OS, x64-processor

12th Gen Intel(R) Core(TM) i9-12950HX 2.30 GHz

NVIDIA RTX A1000 Laptop GPU

32GB RAM

Civil 3D 2021 & Civil 3D 2023

 

Best,

~DD

 

Message 13 of 15

DGCSCAD
Collaborator
Collaborator

I appreciate your taking the time to help DD.

 

I tried uninstalling/reinstalling and same result. I tried using a brand new png. I tried just about everything I can think of and it's got me stumped.

 

The main purpose of this was snazzy dialogs for my functions. I used to use VBA for images in my dialogs but I don't want to have to run a 3rd party installer so everyone can use VBA.

 

I'll keep at it until I figure something out.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 14 of 15

CodeDing
Mentor
Mentor

Have you tried running the "OPENDCLDEMO" palette, then opening the various samples to test those? The "Methods" sample will let you load an image into a picture box (but not a .png for some reason).

 

Might be helpful to see if that produces an error or not.

Message 15 of 15

DGCSCAD
Collaborator
Collaborator

I'll have a look when I get back to this, DD. I'm on a different project right now. Thanks again for all the help! 🙂

AutoCad 2018 (full)
Win 11 Pro
0 Likes