Error bad argument type numberp nil

Hi, i am relatively new to autolisp and i'm getting an error which i don't quite understand. I've got the code shown below which works fine for small values of the COUNT variable. But when i use something like 64 and above, it behaves unexpectedly (at least as far as my expectations go).   When it m...

Visual LISP, AutoLISP and General Customization


Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.


Showing results for 


Search instead for 

Did you mean: 


  • Back to forum


  • Previous

  • Next

ngalonm

2130 Views, 8 Replies

‎08-20-2013

03:45 AM

; error: bad argument type: numberp: nil


Hi, i am relatively new to autolisp and i’m getting an error which i don’t quite understand.

I’ve got the code shown below which works fine for small values of the COUNT variable. But when i use something like 64 and above, it behaves unexpectedly (at least as far as my expectations go).

When it missbehaves it prints less lines that specified by user (in COUNT).

Does anyone have some idea as to what the problem might be?

Thanks in advance. . .

;start
; Function prints a number of lines [pseudo] randomly
; user specifies: COUNT — the number of lines to construct
; MULT — the number by which to scale generated random number (which is in range [0,1) ) before assigning it to x,y,z values of each point

(defun linesr (count mult / prev pt x y z)
(setq prev (list 0 0 0))

(while (> count 0)
(setq x (* (crnd) mult))
(setq y (* (crnd) mult))
(setq z (* (crnd) mult))
(setq pt (list x y z))
(command «line» prev pt «»)

;(print «[count: «)
;(print count)
;(print «; prev «)
;(print prev)
;(print «; cur-pt: «)
;(print pt)
;(print «]»)

(setq prev pt)
(setq count (- count 1))
)
(princ)
)
;end

Also, acad gives me this error message:

  • ; error: bad argument type: numberp: nil

But when i print the COUNT value it seems to be fine hence my lack of understanding and i don’t see any nil values


  • Back to forum


  • Previous

  • Next

8 REPLIES 8

bhull1985

‎08-20-2013

04:27 AM

Not sure, hard to tell.

I loaded your program into cad and it gave me another error message, after adding «C:» to the defun statement so we can invoke it from the command line.

Command: (LOAD «…/misc Lisp/count.lsp») C:LINESR
Command: linesr
; error: too few arguments

which is fine, I suppose, as I didn’t give it any arguments.

You can use prompts and alerts and princs and getstring getnum functions to receive user input and assign the arguments to your program

(if (setq count (getnum «nCount?»))

(progn

[your routine here]

); progn

); if

would be one way to do it that may help the users to enter the correct information so that the program works.

Beyond that, i’m too new to do any sort of effective debugging but those were my first thoughts as to what may help.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let’s keep it trim people!

Lee_Mac

‎08-20-2013

04:30 AM

The error message: ‘bad argument type: numberp: nil‘ indicates that you are passing a null value to a function requiring a numerical argument (more information on common error messages is included in my troubleshooter here).

After a cursory glance, your code looks correct to me, that is, assuming that the ‘crnd‘ function is correctly defined to return a numerical value.

Given your error I could only assume that either the function is not being supplied with two numerical arguments, or that the crnd function is returning a nil value at some point.

For concision, I would write your function in the following way:

(defun randomlines ( num mlt / p1 p2 )
    (setq p1 '(0.0 0.0 0.0))
    (repeat num
        (repeat 3 (setq p2 (cons (* (LM:rand) mlt) p2)))
        (command "_.line" "_non" p1 "_non" (setq p1 p2) "")
        (setq p2 nil)
    )
    (princ)
)

;; Rand  -  Lee Mac
;; PRNG implementing a linear congruential generator with
;; parameters derived from the book 'Numerical Recipes'

(defun LM:rand ( / a c m )
    (setq m   4294967296.0
          a   1664525.0
          c   1013904223.0
          $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m)
    )
    (/ $xn m)
)

The LM:rand function is from my site here.

Lee_Mac

bhull1985

‎08-20-2013

04:32 AM

Oh excellent,

do yourself a favor and follow Lee Mac’s suggestion over mine.

I just wanted to give you something to go on and had almost mentioned some of the brilliants that would be better suited to help you out,

but he was already on it, it seems.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let’s keep it trim people!

Kent1Cooper

‎08-20-2013

06:41 AM

I agree with Lee_Mac’s assessment of the source of the error message.

Here’s a way to do that using only one Line command, which with large count values makes a quite noticeable difference in the amount of time it takes, compared to invoking a new Line command separately for each Line.  [In a quickie comparison, it drew 500 Lines virtually instantaneously, vs. almost 3 seconds for your original and Lee_Mac’s routine.]  And if you’re not going to suppress command echoing, it puts a heck of a lot less up on the Command: line — one line per segment instead of three.  It also uses no variables, just the two arguments.

(defun linesr (count mult)
  (command «_.line» ‘(0 0 0))
  (repeat count
    (command ; feed out
      (list (* (crnd) mult) (* (crnd) mult) (* (crnd) mult))
    ); command
  ); repeat
  (command «»); end Line command
); defun

You should also turn Osnap off.

Kent Cooper, AIA

Lee_Mac

‎08-20-2013

06:56 AM

Good modifications Kent Smiley Happy

pvthoan

‎10-22-2014

08:50 AM

Please help me check my autolisp Code

My code has «error: bad argument type: numberp: nil». now I need it to do the job. please fix it for me. Thank you so much.

; Convert angle (degrees to radians)
(defun dtr(a)
(* pi (/ a 180.0))
)
; Convert angle (radians to degrees)
(defun rtd(a)
(* 180 (/ a pi))
)
(defun C:Gear()
(expand 10)
; Input parameter
(setq module (getreal «tModule(mm) ? «)
radpit (getreal «tPitch radius(mm) ? «)
teenum (getint «tNumber of teeth ? «)
angpre (getreal «tPressure angle(degrees) ? «)
offset (getreal «tCutter offset for addendum modification is(usually 0) ? «)
dist1 0.1
angpre (dtr angpre)
modadd (/ offset module);addendum modification factor
alpha 1.25
beta 1.00
gamma 0.25
addum (* alpha module);addendum gear rack
radadd (+ (/ (* teenum module) 2.0) (* (+ 1 modadd) module));addendum radii
dedum (* beta module);dedendum gear rack
radded (- radpit (* module 1.25));dedendum radii
rc (* module gamma);tip radius
angset 0.0 ;increment angle
angjoi 0.0
angend 0.0
angsta 0.0
keypoint 0.0
angcal 0.0 ;test angle
anginc 0.05
)
(command «circle» (list 0.0 0.0) radadd)
(command «circle» (list 0.0 0.0) radpit)
(command «circle» (list 0.0 0.0) (* radpit (cos angpre)))
(command «circle» (list 0.0 0.0) radded)
(command «line» (list 0.0 0.0) (list 0.0 138.0)»»)
(setq U
(- 0
(+
(/ pi 4.0)
(*
(- alpha gamma)
(/ (sin angpre) (cos angpre))
)
(/ gamma (cos angpre))
)
)
)
(setq V
(- gamma alpha)
)
(setq angjoi
(*
(/ 2.0 teenum)
(+ U
(* (+ V modadd)
(/ (cos angpre) (sin angpre))
)
)
)
)
(setq angsta
(-
(*
(/ 1 (* teenum (cos angpre)))
(sqrt
(-
(expt (+ 2.0 teenum (* 2.0 modadd)) 2.0)
(expt (* teenum (cos angpre)) 2.0)
)
)
)
(*
(+ 1 (/ (* 2.0 modadd) teenum))
(/ (sin angpre) (cos angpre))
)
(/ pi (* 2.0 teenum))
)
)
(setq angset angsta)
(while (>= angset angjoi)
(setq
angcal angset
xinv
(*
(/ (* teenum module) 2.0)
(-
(sin angcal)
(*
(+
(*
(+ angcal (/ pi (* 2.0 teenum)))
(cos angpre)
)
(*
(/ (* 2.0 modadd) teenum)
(sin angpre)
)
)
(cos (+ angcal angpre))
)
)
)
yinv
(*
(/ (* teenum module) 2.0)
(+
(cos angcal)
(*
(+
(*
(+ angcal (/ pi (* 2.0 teenum)))
(cos angpre)
)
(*
(/ (* 2.0 modadd) teenum)
(sin angpre)
)
)
(sin (+ angcal angpre))
)
)
)
pt1
(list xinv yinv)
)
(setq
angcal (- angset anginc)
xinv
(*
(/ (* teenum module) 2.0)
(-
(sin angcal)
(*
(+
(*
(+ angcal (/ pi (* 2.0 teenum)))

(cos angpre)
)
(*
(/ (* 2.0 modadd) teenum)
(sin angpre)
)
)
(cos (+ angcal angpre))
)
)
)
yinv
(*
(/ (* teenum module) 2.0)
(+
(cos angcal)
(*
(+
(*
(+ angcal (/ pi (* 2.0 teenum)))
(cos angpre)
)
(*
(/ (* 2.0 modadd) teenum)
(sin angpre)
)
)
(sin (+ angcal angpre))
)
)
)
pt2
(list xinv yinv)
dist2
(distance pt1 pt2)
)
(if (> dist2 dist1)
(setq
anginc (* anginc 0.999)
)
(if (< dist2 (* dist1 0.999))
(setq
anginc (* anginc 1.001)
)
(progn
(setq
angset
(- angset anginc)
keypoint
(1+ keypoint)
dist1
dist2
)
(command «point» pt1)
)
)
)
)
(setq angset angjoi)
(setq angend (/ (* 2.0 U) teenum))
(while (<= angset angend)
(setq
angcal (+ angset anginc)
L
(sqrt
(+ 1
(* 4.0
(expt (/ (+ V modadd) (- (* 2.0 U) (* teenum angcal))) 2.0)
)
)
)
)
(setq P (+ (/ gamma L) (- U (/ (* teenum angcal) 2.0))))
(setq Q
(+
(*
(/ (* 2.0 gamma) L)
(/ (+ V modadd) (- (* 2.0 U) (* teenum angcai)))
)
V
(/teenum 2.0)
modadd
)
)
(setq
xtroch
(* module (+ (* Q (sin angcal)) (* P (cos angcal))))
ytroch
(* module (- (* Q (cos angcal)) (* P (sin angcal))))
pt2
(list xtroch ytroch)
dist2
(distance pt1 pt2)
)
(if (> dist2 dist1)
(setq
anginc (* anginc 0.99)
)
(if (< dist2 (* distl 0.65))

(setq
anginc (* anginc 1.1)
)
(progn
(setq
angset
(+ angset anginc)
keypoint
(1+ keypoint)
dist1
dist2
pt1
pt2
)
(command «point» pt1)
)
)
)
)
(command «»)
)

Kent1Cooper

‎10-22-2014

11:32 AM


@pvthoan wrote:

Please help me check my autolisp Code

My code has «error: bad argument type: numberp: nil». now I need it to do the job. please fix it for me. Thank you so much.

….

(setq module (getreal «tModule(mm) ? «)
radpit (getreal «tPitch radius(mm) ? «)
teenum (getint «tNumber of teeth ? «)
….


Does it always have that problem, or does it sometimes work correctly?  That message means that an AutoLISP function that wants a numerical value to work with is being given nil instead.  Among other possibilities, that could be the result of the User hitting Enter at any of those prompts that are asking for numerical values with (getreal) or (getint) functions.  There does not seem to be anything in the code to prevent that, or to ask again if the User doesn’t give a valid answer to the prompt.  Test-running it in the VLIDE interface should reveal where the problem is.  You can also just run the command, and then check the values in the variables, by typing the variable names with preceding exclamation points:

!module

!radpit

!teenum

… etc. …

When you find one that returns nil instead of a number, that’s a good clue to where things are going wrong.  But since none of the variables are localized, they will still be there after the command is run, so try it in a new drawing that doesn’t have any chance of old variable values.

If it always fails, it could be something simple such as that a variable name is just misspelled in the code, so check for consistency there.

Kent Cooper, AIA


  • Back to forum


  • Previous

  • Next

I am writing a function that removes background mask from all mtext, however, I am getting a bad argument type: numberp: nil error after running the code:

(defun c:bgm ()
    (vl-load-com)
    (setq ss1 (ssget "X" '((0 . "MTEXT")(-4 . "<OR")(90 . 1)(90 . 3)(-4 . "OR>")))); selects all mtext with background mask on
    (setq sscount (sslength ss1))
    (repeat sscount
        (setq mtxtobj (entget (vlax-vla-object->ename (ssname ss1 counter))))
        (vla-put-backgroundfill mtxtobj :vlax-false)
        (entmod mtxtobj)
    )
)

Any ideas why?

asked Jun 23, 2018 at 12:13

Kevin Chiha's user avatar

There are a number of issues with your code:

  1. If the ssget expression does not obtain a selection (i.e. if there are no objects present in the drawing which fulfil the selection criteria), then ssget will return nil, and consequently the sslength function will error when supplied with a null argument.

    To avoid this, test the value returned by the ssget function using an if statement before proceeding with the remaining code:

    (if (setq ss1 (ssget "_X" '((0 . "MTEXT") (-4 . "<OR") (90 . 1) (90 . 3) (-4 . "OR>"))))
        (progn
            (setq sscount (sslength ss1))
            ...
        )
    )
    
  2. You reference the variable counter in your ssname function, which is not defined in the scope of the c:bgm function:

    (ssname ss1 counter)
    

    This should instead be sscount as defined earlier in your code.

  3. You seem to be confused between entity names and vla-objects:

    • ssname returns an entity name, however, you are passing this to the vlax-vla-object->ename function, which converts a vla-object to an entity name.

    • You are using the vla-put-backgroundfill function to change the backgroundfill property of a vla-object, however, you are passing this function the variable defined by the value returned by entget, which is a DXF data list, not a vla-object.

    • You are using entmod to modify the DXF data assigned to the variable mtxtobj — this is not required when changing ActiveX properties of a vla-object.


Taking the above into consideration, I would suggest the following solution:

(defun c:bgm ( / cnt obj sel )
    (if (setq sel (ssget "_X" '((0 . "MTEXT") (-4 . "<OR") (90 . 1) (90 . 3) (-4 . "OR>"))))
        (repeat (setq cnt (sslength sel))
            (setq cnt (1- cnt)
                  obj (vlax-ename->vla-object (ssname sel cnt))
            )
            (vla-put-backgroundfill obj :vlax-false)
        )
    )
    (princ)
)
(vl-load-com) (princ)

answered Jun 24, 2018 at 10:11

Lee Mac's user avatar

Lee MacLee Mac

15.3k6 gold badges33 silver badges77 bronze badges

1

The error is probably due to:

(ssname ss1 counter)

where counter is nil.
You should use sscount instead. You also have to decrement the sscount value to iterate through the selection set.

(defun c:bgm (/ ss1 sscount)
  (vl-load-com)
  (if (setq ss1 (ssget "X" '((0 . "MTEXT") (-4 . "<OR") (90 . 1) (90 . 3) (-4 . "OR>"))))
    (repeat (setq sscount (sslength ss1))
      (setq sscount (1- sscount)
        mtxtobj (vlax-vla-object->ename (ssname ss1 sscount))
      )
      (vla-put-backgroundfill mtxtobj :vlax-false)
    )
  )
)

answered Jun 23, 2018 at 17:41

gileCAD's user avatar

gileCADgileCAD

2,2251 gold badge9 silver badges10 bronze badges

1

Issue

You received an error message beginning with the words Error: ‘Bad argument type’. Here are some examples:

  • Error: ‘Bad argument type: Numberp nil’
  • Error: ‘Bad argument type: Stringp nil’
  • Error: ‘Bad argument type: VLA-object nil’
  • Error: ‘Bad argument type: lentityp nil’
  • Error: ‘Bad argument type: VLA-object-collection’
  • Sys-error: ‘Bad argument type: 2D/3D point: nil’
  • Error: ‘Bad argument type: consp nil’
  • Error: ‘Bad argument type: INT nil’

Solution

You might see any number of possible errors that begin with Bad argument type, Before getting into the specific error you saw, it’s important to go through a few simple troubleshooting steps:

• What to do first when you see a Bad Argument Type error

If you receive any error message that includes the text «bad argument type» – including all specific error messages listed on this page – go through the following three steps before getting into any of the various bad argument type error messages listed below. Any bad argument type error can potentially stem from either drawing corruption or a bug in the code, so you’ll need to either rule out or resolve these two causes first.

Step 1: Take a screenshot of the error report

Immediately after receiving the error, press the F2 key on your keyboard. Pressing F2 will open the error report in your AutoCAD Command line, and you’ll be able to see actually generated the bad argument error. It’s important that you take a screenshot of the error report in the Command line and save it to your desktop. You may need it later to figure out what caused the error, and we may ask you to send that screenshot to our tech support team to help us diagnose the issue. 

Closed the error message already? No worries – just do the same thing you did to get the error (place a plant, select a valve, etc.). The error will likely pop up again and you can press F2 and screenshot the error report.

Step 2: Rule out, or address, drawing corruption

Bad argument type errors often result from corruption in your drawing. To check for corruption, open a fresh new DWG drawing file and try the same action that generated the error. For example, if you saw the error immediately after placing a plant or setting your drawing scale, do that same thing in the blank drawing. 

***Important***: It’s crucial that you follow our specific steps to duplicate an error in a blank drawing.

  • Did you get the same bad argument type error in the blank drawing? If so, move on to Step 3.
  • Were you able to complete the same action in the blank drawing without generating the error? If so, the issue is almost certainly the result of drawing corruption. Here’s what to do:

1. Open the file where you first saw the error, and follow our steps to clean your drawing.

2. Configure our recommended settings for showing Proxy information. These settings will help you determine whether your drawing file is still corrupt.

3. Open the cleaned drawing file. If you configured the Proxy information settings correctly, you should see a Proxy Information dialog box immediately. Does this dialog box show no Proxy Objects? If so, your file is clean. Now try the same action (placing a plant, setting the scale, etc.) that generated the error.

  • No error? You’ve resolved the issue.
  • Still getting a bad argument type error? Move on to Step 3.  

Step 3: Check for a bug in the code

Once you’ve either ruled out or addressed drawing corruption, it’s time to check whether the error is the result of a bug in the code of our software.

Note that a bad argument type error will always mean that a variable in the code is not what the system is expecting. In fact, it could be the result of a simple bug – the most common of which is a typo in the code. In this case, the “object” in question may be just fine, but the variable name was mistyped in the code. (Yes, even programmers are human!) So of course the misspelled version is certainly not an object reference and is therefore nil – hence the error message.

The easiest way to check for a bug is to check our list of recent updates.

  • Don’t see a recent update that’s related to what you tried to do when you saw the error? You’ve likely ruled out a bug. It’s time to locate and address the specific bad argument type error message you’re seeing.
  • Do you see a recent update that’s related to what you tried to do when you saw the error? If so, there’s a good chance you’ve detected a bug in the code. For example, if you saw a bad argument type error when you attempted to place a Reference Note Callout, and a recent update has to do with Reference Note Callouts, there’s your bug! If you think you’ve found a bug, please let us know by sending us a technical support ticket. Make sure to include the following items in the ticket:

    • The exact text of the error message, and a screenshot of the error message (if you have it)
    • A description of the action you took that generated the error message (such as placing a plant, editing a detail, etc.)
    • A screenshot of the error report you generated by pressing the F2 key after seeing the error message. Don’t have a screenshot? Just do the same thing that caused the error. You’ll see the bad argument type error message. Press F2 now, and take a screenshot of the entire AutoCAD Command line. Include this screenshot in the technical support ticket.

Based on your ticket, we’ll take a look at the code and determine whether there is indeed a bug. If so, we’ll get right on repairing it in an update. You’ve helped us improve the software!

 Close

Specific ‘Bad Argument Type’ Errors

If you went through the «What to do first» steps above and are still seeing the error, it’s time to get into the specific Bad argument type error you’re seeing.

We’re continually logging the causes and solutions of new Bad argument type errors as we see them. Here are the specific ones we’ve seen:

• Error: ‘Bad argument type: Numberp: nil’

  • If you saw this error when trying to use our Nuke tool, your Proxy settings are configured incorrectly. Please follow our recommendations for the Proxy settings in the Options dialog box. You should then be able to Nuke properly.
  • Are you getting this message when using our Verify tool for Lighting? If so, make sure you don’t have any looped wire sections in your wire paths to fixtures.
  • Otherwise, this error will invariably be the result of drawing corruption. Follow our steps to clean your drawing.

 Close

• Error: ‘Bad argument type: Stringp nil’

You might see this error when you:

  • Tried to use our Verify Labels tool, or when working specifically with plants.
  • Had our Color Render tool turned on.
  • Attempted to open AutoCAD or F/X CAD, and it completely froze.
  • Tried to add a dripline hatch to your project.
  • Tried to place a block from our Discipline Graphics library

As you can see, this particular Bad argument error has several possible causes and, as a result, potential solutions. See our Error: ‘Bad Argument Type: Stringp Nil’ article to find your solution.

 Close

• Error: ‘Bad argument type: VLA-OBJECT nil’

A bad argument type error containing the text VLA-object nil means the software is expecting something in your drawing to be a «smart» object, but a variable in the code has caused that thing to not actually be an object. (In other words, it’s nil.) As a result, the software was not able to reference that object, which in turn prevented it from carrying out the action you were trying to complete and generated the error message.

As for the actual issue, it will depend on what you were trying to do when you received the error, as well as which object reference is now nil. Here are a few possible causes:

  • You have Local Data (MySQL), and your database connection object is nil

First, make absolute sure that you’ve followed our steps for what to do first when you see a bad argument type error – especially Step 3: Check for a bug in the code. Take note of exactly what you did (or tried to do) that resulted in the error, and check it against our recent updates, as described in those steps. 

If you can rule out a bug in the software based on those steps, your next step should be to diagnose a possible problem with your MySQL database server – but only if you’re using our software with a local (MySQL) database. Ask your IT administrator to troubleshoot your office’s MySQL database server, as described on our slow Land F/X performance troubleshooting article. Don’t know whether you’re using Local Data? Your CAD manager or IT admin can let you know.

  • You attempted to create a colorized plan using our Color Render tool 

In this case, the problematic object is a Truecolor object. If you’re getting this error every time you try to apply plant color, you can repair the error by following our steps to uninstall and reinstall AutoCAD or F/X CAD.

  • An XML file is damaged or missing

Are you getting this error right when opening CAD? Is CAD freezing up and you’re unable to use our software? If so, a file named _install_.xml, stored in your LandFX folder, is likely damaged or missing.

In this case, follow our steps to restore the install.xml file.

  • You attempted to perform one of several possible actions with a detail

Finally, you might receive this error when working with a detail. For example, you may have tried to edit, save, copy, or place a detail when you received the error.

In this case, the system is unable to read or write in that detail’s XML file. This can occur for several possible reasons:

  • You don’t have read/write permissions for the folder where that XML file lives. Have your IT administrator ensure that you have all the proper permissions to work with your office’s details. 
  • Your details are stored at a UNC path, which we don’t recommend. Ask your IT administrator to ensure that the folder containing your details is mapped to a letter drive.
  • Any number of issues with your Windows installation – another potential set of troubleshooting steps for your IT admin to complete.
  • Malware (less common). Your IT administrator should ensure that your computer and network are free of malware.

If you’ve ruled out all of the causes listed above, it’s likely that the XML file is missing from the location where the detail is stored. If so, copy the detail to your desktop and use our Save Detail tool to save it into the system.

Still getting the error? If you’ve ruled out permissions, a UNC path, your Windows installation, and malware, it’s possible that you or someone in your office has attempted to import the detail into a Land F/X project but clicked on the wrong XML file.  

Specifically, this error is the result of importing the file _index_.xml rather than the correct XML file for the detail you intended to import.

Instead, you need to import the XML file from the corresponding exported detail. Open the Detail Explorer and click Import.

You’ll then be prompted to select a detail export file.

Navigate to the location where you’ve exported the detail.

Open that folder, and select the file details.xml. Click Open.

You should now be able to work with that detail without receiving the error.

 Close

• Error: ‘Bad argument type: lentityp nil’

A bad argument type error containing the text lentityp nil can have several possible causes, including:

  • Drawing corruption (most commonly), or a bug in the software code

Make absolute certain that you’ve followed our steps for what to do first when you see a bad argument type error. Those steps include instructions on how to check for corruption in your drawing and how to check for a bug in the software.

Note that drawing corruption is the most common cause of this error. If you detect drawing corruption when completing the «what to do first» steps, follow our steps to clean your drawing and all Xrefs. We always recommend cleaning every single drawing you receive from someone else before you start working on it. Keeping your drawings clean will prevent a host of issues (including this error) and save you tons of time.

  • Locked layers in a drawing that contains callouts

If you’ve ruled out a bug and drawing corruption, the error is likely the result of locked layers that are preventing you from working with callouts in your drawing. These can include:

  • Plant labels
  • Reference Notes (RefNotes) 
  • Detail callouts
  • Valve callouts

To unlock layers in your drawing, see our lock/unlock layers documentation section. Note: We don’t recommend locking layers in your drawings – except those that contain your Xrefs.

At the very least, unlock all layers that contain callouts (or portions of callouts). You should now be able to continue working without seeing the error message.

 Close

• Error: ‘Bad argument type: VLA-object collection, VLA-object’

An error message containing the text ‘Bad argument type: vla-object collection’ is always the result of the software attempting (and failing) to determine which sheet you are working on. You might receive this error when:

  • Setting the drawing scale
  • Working with details or detail callouts
  • Doing anything that requires the software to know which sheet you are working on

Follow our steps to resolve this specific error.

 Close

• Sys-error: ‘Bad argument type: 2D/3D point: nil’

You’ll most commonly see this error when trying place or copy an object, or carry out a similar type of action, using one of our tools. You’re seeing the error because the system is unable to calculate an intersection in your drawing. Specifically, it’s trying (and failing) to calculate the distance between the cursor and the object you’re trying to place, copy, or verify. (We’ve seen it happen with placing plants or irrigation equipment such as valves, or using tools such as our Plant Mirror tool that copy objects in a drawing.)

Here’s a past example of this error message:

 [3.33] (sys-error «bad argument type: 2D/3D point: nil»)

:ERROR-BREAK.28 nil
[4.25] (ANGLE (907.216 795.06 0.0) nil)
[5.19] (C:VALVECALLOUT)

In this example, the user tried to place a valve callout but was unsuccessful because the system was unable to calculate the angle between the cursor and valve that was being called out. (Note that the issue can affect any number of items, from irrigation to plant labeling, site objects, etc.) 

This error most commonly results from:

• Corruption in your drawing

Drawing corruption is by far the most common cause of this error. Your first step should be to follow our instructions to clean the drawing and all Xrefs.

Cleaning your drawing will often take care of the error.

Still seeing the error after cleaning your drawing? Read on.

A bad argument type error containing the text 2D/3D point: nil can also result from:

• A bug in the software code

Make absolute sure you’ve followed our steps for what to do first when you see a bad argument type error – especially Step 3: Check for a bug in the code. Take note of exactly what you did (or tried to do) that resulted in the error, and check it against our recent updates, as described in those steps.

• Working in Paper Space rather than Model Space

Check whether you are working in Paper Space. If so, open the Model tab and work in Model Space. Try the same action that generated the error, but in Model Space. If you don’t see the error, you’ve resolved the issue.

You might also see this error if you’re labeling in a Paper Space viewport with the intention that the labels will be moved to Paper Space. If so, the error is occurring because of a problem with either the viewport or the User Coordinate System (UCS) you’re currently using.

Try labeling in a different Paper Space viewport. If you don’t see the error, you’ve isolated the problem to the other viewport.

• A problem with the current User Coordinate System (UCS)

The UCS you’re currently using for your drawing may have an issue that’s preventing the software from calculating angles between the cursor and objects in your plan. To check for and resolve this issue:

  • Use our Restore UCS tool to return your drawing to the World Coordinate System (WCS). Then try the action that generated the error (such as placing a valve callout).

    • Don’t see the error when attempting the same action in the WCS? If not, use our New UCS tool to set a new UCS for your drawing. Make sure you use our New UCS tool – not the AutoCAD UCS command.
    • Does the error persist in the WCS? If so, make absolute sure you’re working in Model Space and not Paper Space.

• An object with a Z elevation

You might see this error when clicking on an object that mistakenly has a Z elevation set to it. For example, you may be trying to call out a plant or a valve with a Z elevation.

Select the object you clicked.

Then open the Properties panel by typing Prop in the Command line and pressing Enter.

In the Properties panel, check the Position Z entry. If it’s anything other than 0, set it to 0. (If it’s already at 0, the object does not have a Z elevation.)

If you changed the Z elevation to 0, try the action that generated the error. Are you able to click the object without getting the error? You’ve solved the issue.

• Attempting to click objects on a locked layer

You might be trying to select an object on a locked layer. For example, you may be trying to call out a plant or valve whose layer is locked. See our section on locked and unlocked layers for instructions on how to unlock layers.

We generally don’t recommend locking layers – except those that contain your Xrefs.

• Using our Verify Labels tool when one of the blocks in your plan is empty – that is, no linework or objects inside the block

In this case, check the Command line history for the name of the object that caused the error. Check the Land F/X object data to determine which block is assigned. Then use one of the following possible solution options:

Option 1: Edit the data to use a different block that isn’t empty.

Option 2: Fix the empty block by either:

  • Using our Using our REDEFINEBLOCK tool, or
  • Editing the block manually to add linework inside it

Option 3: If using Reference Notes (RefNotes), consider whether the reason for the empty block is that you don’t actually want the block to be visible in your drawing.

If you don’t in fact want the block to be visible, change the RefNote from an Amenity RefNote to a Notation RefNote. Then use the Quick Select command to select and delete all the empty blocks and place Notation callouts instead.

 Close

• Error: ‘Bad argument type: consp nil’

This error can result from:

  • A bug in the software code

Make absolute sure you’ve followed our steps for what to do first when you see a bad argument type error – especially Step 3: Check for a bug in the code. Take note of exactly what you did (or tried to do) that resulted in the error, and check it against our recent updates, as described in those steps.

  • Attempting to select an item in your plan that is no longer in the current Land F/X project 

Once you’ve ruled out a bug, it’s time to check whether an object you’re attempting to select, such as a plant or a piece of irrigation equipment, has been removed from your project. If so, you’ll need to add that item back to your project.

  • A font issue

Did you get this error when trying to place text? Solution >

  • Update didn’t complete

Did you get this error after trying to run an update? The update may not have completed correctly. Follow our steps to Revert to a previous version after an update. Then run the update again and restart your computer.

 Close

• Error: ‘Bad argument type: INT nil’

We’ve seen this error pop up right after clicking the Site Color palette, but you might see it when you select or use other Land F/X tools as welll.

You can resolve this error quickly by following our steps to install the latest OpenDCL library.

 Close

Содержание

  1. AutoCAD
  2. Error bad argument type numberp nil
  3. Solution
  4. Step 1: Take a screenshot of the error report
  5. Step 2: Rule out, or address, drawing corruption
  6. Step 3: Check for a bug in the code
  7. Specific ‘Bad Argument Type’ Errors
  8. Thread: error: bad argument type: numberp: nil
  9. error: bad argument type: numberp: nil
  10. Re: error: bad argument type: numberp: nil
  11. Re: error: bad argument type: numberp: nil

AutoCAD

Creating an autolisp program to add a threaded hole to a selected object, the program is as follows:

; Meghan Hendricks
; HOLETHREAD.LSP
;
(defun c:HOLETHREAD ()
(setq scmde (getvar «cmdecho»))
(setvar «cmdecho» 0)
(setq sblip (getvar «blipmode»))
(setvar «blipmode» 0)
(setq sosmd (getvar «osmode»))
(setvar «osmode» 0)
(setq 3dosmd (getvar «3dosmode»))
(setvar «3dosmode» 0)
(setq dyucs (getvar «ucsdetect»))
(setvar «ucsdetect» 0)
(setq ccolor (getvar «cecolor»))
(setq e1 (entsel «nselect the object»))
(setvar «osmode» 1)
(setq pt1 (getpoint «nEnter location of new coordinate system: «))
(setq pt2 (getpoint «nEnter location of new x axis: «))
(setq pt3 (getpoint «nEnter location of new y axis: «))
(command «ucs» 3 pt1 pt2 pt3)
(setvar «osmode» 0)

(setvar «blipmode» 1)
(setq pt4 (getpoint «nEnter location of center of the hole on the surface: «))
(setvar «blipmode» 0)
(setq D1 (getreal «nInput Diameter of the hole: «))
(setq L1 (getreal «nInput depth of the hole (positive z direction): «))
(setq c (getstring «nColor of hole»))
(command «color» c)
(command «cylinder» pt4 D1 L1)
(setq e2 (entlast))

(if (>= h 0)
(progn ;- z direction
(setq pt5 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) 0))
(setq pt6 (list (car pt4) (- (car pt1) D2) (- (* D1 0.1))))
(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (- (* D1 0.2))))
(setq pt8 (list (car pt4) (cadr pt4) (- (* D1 0.1))))
(command «3DPOLY» pt5 pt6 pt7 «c»)
(setq e3 (entlast))
(command «helix» pt8 (* 0.4 D1)(* 0.4 D1) «H» (* 0.41 R2) (+ (* 0.4 R2) L1))
(setq e4 (entlast))
(command «sweep» e3 «» «a» «n» e4 «»)
(setq e5 (entlast))
(command «subtract» e2 «» e5 «»)
(setq e6 (entlast))
)
(progn ;+z direction
(setq pt5 (list (car pt4) (+ (cadr pt1) (* D2 0.4)) 0))
(setq pt6 (list (car pt4) (- (car pt1) D2) (* D1 0.1)))
(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (* D1 0.1)))
(setq pt8 (list (car pt4) (cadr pt4) (* D1 0.1)))
(command «3DPOLY» pt5 pt6 pt7 «c»)
(setq e3 (entlast))
(command «helix» pt8 (* 0.4 D1)(* 0.4 D1) «H» (* 0.41 R2) (+ (* 0.4 R2) L1))
(setq e4 (entlast))
(command «sweep» e3 «» «a» «n» e4 «»)
(setq e5 (entlast))
(command «subtract» e2 «» e5 «»)
(setq e6 (entlast))
))
(command «subtract» e1 «» e6 «»)

(command «ucs» «p»)
(command «vpoint» (list 1 -1 1))
(command «vscurrent» 2) ;2d wireframe

(setvar «cecolor» ccolor)
(setvar «blipmode» sblip)
(setvar «cmdecho» scmde)
(setvar «osmode» snp)
(setvar «3dosmode» 3dosmd)
(setvar «ucsdetect» dyucs)
)

the program gets as far as creating the cylinder or diameter of D1 and then i get the error

«error: bad argument type: numberp: nil»

R2 is not being set, unless it’s coming from somewhere else not shown in this code.

Creating an autolisp program to add a threaded hole to a selected object, the program is as follows:

; Meghan Hendricks
; HOLETHREAD.LSP
;
(defun c:HOLETHREAD ()
(setq scmde (getvar «cmdecho»))
(setvar «cmdecho» 0)
(setq sblip (getvar «blipmode»))
(setvar «blipmode» 0)
(setq sosmd (getvar «osmode»))
(setvar «osmode» 0)
(setq 3dosmd (getvar «3dosmode»))
(setvar «3dosmode» 0)
(setq dyucs (getvar «ucsdetect»))
(setvar «ucsdetect» 0)
(setq ccolor (getvar «cecolor»))
(setq e1 (entsel «nselect the object»))
(setvar «osmode» 1)
(setq pt1 (getpoint «nEnter location of new coordinate system: «))
(setq pt2 (getpoint «nEnter location of new x axis: «))
(setq pt3 (getpoint «nEnter location of new y axis: «))
(command «ucs» 3 pt1 pt2 pt3)
(setvar «osmode» 0)

(setvar «blipmode» 1)
(setq pt4 (getpoint «nEnter location of center of the hole on the surface: «))
(setvar «blipmode» 0)
(setq D1 (getreal «nInput Diameter of the hole: «))
(setq L1 (getreal «nInput depth of the hole (positive z direction): «))
(setq c (getstring «nColor of hole»))
(command «color» c)
(command «cylinder» pt4 D1 L1)
(setq e2 (entlast))

(if (>= h 0)
(progn ;- z direction
(setq pt5 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) 0))
(setq pt6 (list (car pt4) (- (car pt1) D2) (- (* D1 0.1))))
(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (- (* D1 0.2))))
(setq pt8 (list (car pt4) (cadr pt4) (- (* D1 0.1))))
(command «3DPOLY» pt5 pt6 pt7 «c»)
(setq e3 (entlast))
(command «helix» pt8 (* 0.4 D1)(* 0.4 D1) «H» (* 0.41 R2) (+ (* 0.4 R2) L1))
(setq e4 (entlast))
(command «sweep» e3 «» «a» «n» e4 «»)
(setq e5 (entlast))
(command «subtract» e2 «» e5 «»)
(setq e6 (entlast))
)
(progn ;+z direction
(setq pt5 (list (car pt4) (+ (cadr pt1) (* D2 0.4)) 0))
(setq pt6 (list (car pt4) (- (car pt1) D2) (* D1 0.1)))
(setq pt7 (list (car pt4) (+ (cadr pt1) (* D1 0.4)) (* D1 0.1)))
(setq pt8 (list (car pt4) (cadr pt4) (* D1 0.1)))
(command «3DPOLY» pt5 pt6 pt7 «c»)
(setq e3 (entlast))
(command «helix» pt8 (* 0.4 D1)(* 0.4 D1) «H» (* 0.41 R2) (+ (* 0.4 R2) L1))
(setq e4 (entlast))
(command «sweep» e3 «» «a» «n» e4 «»)
(setq e5 (entlast))
(command «subtract» e2 «» e5 «»)
(setq e6 (entlast))
))
(command «subtract» e1 «» e6 «»)

(command «ucs» «p»)
(command «vpoint» (list 1 -1 1))
(command «vscurrent» 2) ;2d wireframe

(setvar «cecolor» ccolor)
(setvar «blipmode» sblip)
(setvar «cmdecho» scmde)
(setvar «osmode» snp)
(setvar «3dosmode» 3dosmd)
(setvar «ucsdetect» dyucs)
)

the program gets as far as creating the cylinder or diameter of D1 and then i get the error

Источник

Error bad argument type numberp nil

You received an error message beginning with the words Error: ‘Bad argument type’. Here are some examples:

  • Error: ‘Bad argument type: Numberp nil’
  • Error: ‘Bad argument type: Stringp nil’
  • Error: ‘Bad argument type: VLA-object nil’
  • Error: ‘Bad argument type: lentityp nil’
  • Error: ‘Bad argument type: VLA-object-collection’
  • Sys-error: ‘Bad argument type: 2D/3D point: nil’
  • Error: ‘Bad argument type: consp nil’
  • Error: ‘Bad argument type: INT nil’

Solution

You might see any number of possible errors that begin with Bad argument type, Before getting into the specific error you saw, it’s important to go through a few simple troubleshooting steps:

If you receive any error message that includes the text «bad argument type» – including all specific error messages listed on this page – go through the following three steps before getting into any of the various bad argument type error messages listed below. Any bad argument type error can potentially stem from either drawing corruption or a bug in the code, so you’ll need to either rule out or resolve these two causes first.

Step 1: Take a screenshot of the error report

Immediately after receiving the error, press the F2 key on your keyboard. Pressing F2 will open the error report in your AutoCAD Command line, and you’ll be able to see actually generated the bad argument error. It’s important that you take a screenshot of the error report in the Command line and save it to your desktop. You may need it later to figure out what caused the error, and we may ask you to send that screenshot to our tech support team to help us diagnose the issue.

Closed the error message already? No worries – just do the same thing you did to get the error (place a plant, select a valve, etc.). The error will likely pop up again and you can press F2 and screenshot the error report.

Step 2: Rule out, or address, drawing corruption

Bad argument type errors often result from corruption in your drawing. To check for corruption, open a fresh new DWG drawing file and try the same action that generated the error. For example, if you saw the error immediately after placing a plant or setting your drawing scale, do that same thing in the blank drawing.

***Important***: It’s crucial that you follow our specific steps to duplicate an error in a blank drawing.

  • Did you get the same bad argument type error in the blank drawing? If so, move on to Step 3.
  • Were you able to complete the same action in the blank drawing without generating the error? If so, the issue is almost certainly the result of drawing corruption. Here’s what to do:

1. Open the file where you first saw the error, and follow our steps to clean your drawing.

2. Configure our recommended settings for showing Proxy information. These settings will help you determine whether your drawing file is still corrupt.

3. Open the cleaned drawing file. If you configured the Proxy information settings correctly, you should see a Proxy Information dialog box immediately. Does this dialog box show no Proxy Objects? If so, your file is clean. Now try the same action (placing a plant, setting the scale, etc.) that generated the error.

  • No error? You’ve resolved the issue.
  • Still getting a bad argument type error? Move on to Step 3.

Step 3: Check for a bug in the code

Once you’ve either ruled out or addressed drawing corruption, it’s time to check whether the error is the result of a bug in the code of our software.

Note that a bad argument type error will always mean that a variable in the code is not what the system is expecting. In fact, it could be the result of a simple bug – the most common of which is a typo in the code. In this case, the “object” in question may be just fine, but the variable name was mistyped in the code. (Yes, even programmers are human!) So of course the misspelled version is certainly not an object reference and is therefore nil – hence the error message.

The easiest way to check for a bug is to check our list of recent updates.

  • Don’t see a recent update that’s related to what you tried to do when you saw the error? You’ve likely ruled out a bug. It’s time to locate and address the specific bad argument type error message you’re seeing.
  • Do you see a recent update that’s related to what you tried to do when you saw the error? If so, there’s a good chance you’ve detected a bug in the code. For example, if you saw a bad argument type error when you attempted to place a Reference Note Callout, and a recent update has to do with Reference Note Callouts, there’s your bug! If you think you’ve found a bug, please let us know by sending us a technical support ticket. Make sure to include the following items in the ticket:
    • The exact text of the error message, and a screenshot of the error message (if you have it)
    • A description of the action you took that generated the error message (such as placing a plant, editing a detail, etc.)
    • A screenshot of the error report you generated by pressing the F2 key after seeing the error message. Don’t have a screenshot? Just do the same thing that caused the error. You’ll see the bad argument type error message. Press F2 now, and take a screenshot of the entire AutoCAD Command line. Include this screenshot in the technical support ticket.

Based on your ticket, we’ll take a look at the code and determine whether there is indeed a bug. If so, we’ll get right on repairing it in an update. You’ve helped us improve the software!

Specific ‘Bad Argument Type’ Errors

If you went through the «What to do first» steps above and are still seeing the error, it’s time to get into the specific Bad argument type error you’re seeing.

We’re continually logging the causes and solutions of new Bad argument type errors as we see them. Here are the specific ones we’ve seen:

Источник

Thread: error: bad argument type: numberp: nil

Thread Tools
Display

error: bad argument type: numberp: nil

I’ve just codged up a routine which sets LTscale in an existing drawing and then modifies individually set linetype scales to suit. Seems to work fine in a test drawing using a variety of linetypes, scales etc. but falls over in a real drawing. I’m not familiar with VLIDE but Last Break Source seems to indicate something wrong in the line ‘scl (/ scl dmscl)’ but I don’t know how to check variable contents. Can anyone give some clues?

Re: error: bad argument type: numberp: nil

DXF code 48 is optional; when the entity’s ltscale =1 the DXF code 48 may not be available with entget.
You could use the IF function to check if (cdr(assoc 48 1stEnt))=nil. if nil set scl=1.

You can check variables content by using the Watch window in Vlide. It’s use is explained here.
http://www.afralisp.net/vl/vl-edit.htm

Last edited by lpseifert; 2010-03-05 at 12:47 PM .

Re: error: bad argument type: numberp: nil

Old chestnut I’m afraid.

I’ve just codged up a routine which sets LTscale in an existing drawing and then modifies individually set linetype scales to suit. Seems to work fine in a test drawing using a variety of linetypes, scales etc. but falls over in a real drawing. I’m not familiar with VLIDE but Last Break Source seems to indicate something wrong in the line ‘scl (/ scl dmscl)’ but I don’t know how to check variable contents. Can anyone give some clues?

I believe it is failing here: (cdr (assoc 48 1stEnt))

From the help:
48 Linetype scale (optional) 1.0

In my tests I found that in some instances it did not exists so you will have to add it.
(setq 1stEnt (cons (cons 48 1.0) 1stEnt))

Set the scale to what ever it needs to be If it doesn’t exist then it is 1.0

Источник

am using lisp routine ARC-PARK in 2011 and getting this error. Have seen older posts with same error, but not code savvy. None specifically addressing this lisp.

any help would be greatly appreciated.

;Tip1815: ARC-PARK.LSP PARKING ON AN ARC ©2002, Ron Engberg

;; This routine allows the user to place parking stalls along an arc.

;;

;; Written by Ron Engberg 12-2000

;; Radians to degrees

(defun RTD ® (* (/ R pi) 180))

;; Degrees to Radians

(defun DTR ® (/ (* 2 pi) 360))

(defun

C:ARC-PARK (/ ENT ARC-PT1 STALL-W STALL-L ARC-SIDE ARC-DIR

STALL-COUNT ARC_LIST ARC-CPT ARC-DIAM S-ANG E-ANG

ARC-CIRC DELTA ARC-LENGTH STALL-ANGLE-IN STALL-ANGLE-OUT

ARC-BASE ARC-ROT-ANGLE

)

;; Screen echo off

(setvar «cmdecho» 0)

;; Set to World UCS

(command «ucs» «w»)

;; Parking stall information

(setq ENT (entsel «nSelect ARC: «))

(initget 1)

(setq ARC-PT1 (getpoint «nStarting End of ARC: «))

(initget 7)

(setq STALL-W (getreal «nStall Width: «))

(initget 7)

(setq STALL-L (getreal «nStall Length: «))

(setq ARC-SIDE (getstring «nInside or Outside : «))

(setq

ARC-DIR

(getstring «nClockwise or Counter Clockwise : «)

) ;_ end of setq

(initget 7)

(setq STALL-COUNT (getint «nNumber of Stalls: «))

;; Arc information

(setq ARC_LIST (entget (car ENT)))

(setq ARC-CPT (cdr (assoc 10 ARC_LIST))) ;center point

(setq ARC-DIAM (* (cdr (assoc 40 ARC_LIST)) 2)) ;arc diameter

(if (or (= ARC-SIDE «I») (= ARC-SIDE «i»))

(setq ARC-DIAM (- ARC-DIAM (* 2 STALL-L)))

) ;_ end of if

(setq

S-ANG

(cdr (assoc 50 ARC_LIST)) ;start angle

E-ANG

(cdr (assoc 51 ARC_LIST)) ;end angle

ARC-CIRC

(* pi ARC-DIAM) ;arc circumference

;arc length

) ; end arc info

;; Test for delta angle

(if (> S_ANG E_ANG)

(setq DELTA (+ (- 6.2831853 S-ANG) E-ANG))

(setq DELTA (abs (- S-ANG E-ANG)))

) ; end if

(setq ARC-LENGTH (* (cdr (assoc 40 ARC_LIST)) DELTA))

;; Angle for starter line

(setq

STALL-ANGLE-IN

(angle ARC-PT1 ARC-CPT) ;stalls inside arc

STALL-ANGLE-OUT

(angle ARC-CPT ARC-PT1) ;stalls outside arc

) ; end set group

;; Rotation info

(setq

ARC-BASE

(/ ARC-CIRC 360.0000) ;length per degree

ARC-ROT-ANGLE

(/ STALL-W ARC-BASE) ;degrees per stall

) ; end set group

;; Test for inside or outside

(if (or (= ARC-SIDE «I») (= ARC-SIDE «i»)) ;case sensitive ?

(command «line» ARC-PT1 (polar ARC-PT1 STALL-ANGLE-IN STALL-L) «»)

;if inside

(command «line» ARC-PT1 (polar ARC-PT1 STALL-ANGLE-OUT STALL-L) «»)

;else, outside

) ;end if

;; Test for clockwise or counter clockwise

(if (or (= ARC-DIR «CCW») (= ARC-DIR «ccw»)) ;case sensitive ?

(progn

(repeat STALL-COUNT

(command «array» «l» «» «P» ARC-CPT «2» ARC-ROT-ANGLE «Y»)

) ;_ end of repeat

) ; if ccw

(progn

(repeat STALL-COUNT

(command

«array»

«l»

«»

«P»

ARC-CPT

«2»

(- ARC-ROT-ANGLE (* 2 ARC-ROT-ANGLE))

«Y»

) ;_ end of command

) ;_ end of repeat

) ; else cw

) ; end if

;; Reset UCS

(command «ucs» «p»)

(princ)

;; Screen echo on

(setvar «cmdecho» 1)

) ;_ end of defun

Topic: ? syntax error in AutoLisp? error: bad argument type: numberp: nil  (Read 3517 times)

0 Members and 1 Guest are viewing this topic.

+X^N

Hello ,
I am learning AutoLisp ;
get error: bad argument type: numberp: nil
.
Am seeking to make new UCS at an angle .
here is the code :

;   Define local FUNCTIONs
(dfnc dist_half(/ x_refl y_refl)  ;; UCS distance X to Point
    (/ (sqrt(+ (expt x_refl 2.0) (expt y_refl 2.0))) 2.0) ;; SquareRoot of X^2 + Y^2 = Hypotenuse
)

(dfnc c:distz-hgt(/ fo_hgt_z reflhgtz)  ;; UCS distance Y to Point
(- fo_hgt_z reflhgtz)
)

;; TESTing 20160911
;  Create UCS  "ReflNN_1"  tipped towards  Point

       (setq point2 '(dist_half(20.8125 20.8125) distz-hgt(0.625) 0) );;  use FUNCTION of distance : from UCS 'horizonatally' to the

   (command "_.ucs" "_3p" (0 0 0) point2 (0 0 1)) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel Center , Tip the UCS towards THE Point ,  UCS Positive Z direction unit ; still need to 'flip  '
   (command "_.ucs" "_na" "_s" "Refl25_1_TEST")

;; end_TESTing 20160911

any help is _pre_appreciated

« Last Edit: September 11, 2016, 06:45:23 PM by +X^N »


Logged


At first glance it looks like;
   (0 0 0) is not a list you need to make it ‘(0 0 0) same with the list after point2.


Logged


+X^N

Calculating the numbers by hand and using in the setq works :

  1. ;; TESTing 20160911

  2. ;  Create UCS ‘tipped’ towards Point «ReflNN_1»

  3. (setq point1 ‘(0 0 0) point2 ‘(14.716659883445020351592573286307 62.375 0) point3 ‘(0 0 1)) ;;  from UCS ‘horizonatally’ to the

  4. (command «_.ucs» «_3p» point1 point2 point3) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel , Tip the UCS towards THE  Point ,  UCS Positive Z direction unit

  5. (command «_.ucs» «_na» «_s» «Refl25_1_TEST»)

  6. ;; end_TESTing 20160911

However , would like to have calculation in the setq  _ as in the first post .

« Last Edit: September 13, 2016, 01:10:14 AM by +X^N »


Logged


Just guessing, but according to your later numerical interpretation, maybe it should look like this :

;   Define local FUNCTIONs
(defun dist_half ( x_refl y_refl )  ;; UCS distance X to Point
  (/ (sqrt (+ (expt x_refl 2.0) (expt y_refl 2.0))) -2.0) ;; SquareRoot of X^2 + Y^2 = Hypotenuse
)

(defun distz-hgt ( fo_hgt_z reflhgtz )  ;; UCS distance Y to Point
  (- fo_hgt_z reflhgtz)
)

;; TESTing 20160911
;  Create UCS  "ReflNN_1"  tipped towards  Point

      (setq point2 (list (dist_half 20.8125 20.8125) (distz-hgt 63.0 0.625) 0.0));;  use FUNCTION of distance : from UCS 'horizonatally' to the

   (command "_.ucs" "_3p" "_non" '(0.0 0.0 0.0) "_non" point2 "_non" '(0.0 0.0 1.0)) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel Center , Tip the UCS towards THE Point ,  UCS Positive Z direction unit ; still need to 'flip  '
   (command "_.ucs" "_na" "_s" "Refl25_1_TEST")

;; end_TESTing 20160911


And I would set point2 variable at the end to nil or localize point2 variable inside main function that haven’t yet been defined…

HTH, M.R.


Logged


+X^N

Just guessing, but according to your later numerical interpretation, maybe it should look like this :

  1. ;   Define local FUNCTIONs

  2. (defun dist_half ( x_refl y_refl )  ;; UCS distance X to Point

  3. (/ (sqrt (+ (expt x_refl 2.0) (expt y_refl 2.0))) 2.0) ;; SquareRoot of X^2 + Y^2 = Hypotenuse

  4. )

  5. (defun distzhgt ( fo_hgt_z reflhgtz )  ;; UCS distance Y to Point

  6. ( fo_hgt_z reflhgtz)

  7. )

  8. ;; TESTing 20160911

  9. ;  Create UCS  «ReflNN_1»  tipped towards  Point

  10. (setq point2 (list (dist_half 20.8125 20.8125) (distzhgt 63.0 0.625) 0.0));;  use FUNCTION of distance : from UCS ‘horizonatally’ to the

  11. (command «_.ucs» «_3p» «_non»(0.0 0.0 0.0) «_non» point2 «_non»(0.0 0.0 1.0)) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel Center , Tip the UCS towards THE Point ,  UCS Positive Z direction unit ; still need to ‘flip  ‘

  12. (command «_.ucs» «_na» «_s» «Refl25_1_TEST»)

  13. ;; end_TESTing 20160911

And I would set point2 variable at the end to nil or localize point2 variable inside main function that haven’t yet been defined…

HTH, M.R.

Thank you _ am just learning — it (mostly) was the need for list (which allows evaluative statements ) ,
rather than ‘ (which seems to act as a literal ) .
.
My trig was incorrect ;
I need to halve the angle not a horiz. dist . (I still need the horiz dist though) .
will start seperate thread .

« Last Edit: September 13, 2016, 01:10:53 AM by +X^N »


Logged


+X^N

Interesting did a quick copy and paste to see what was happening.

Command: (setq point2 ‘((/ (sqrt(+ (expt 20.8125 2.0) (expt 20.8125 2.0))) 2.0) (- 63.0 0.625) 0))
((/ (SQRT (+ (EXPT 20.8125 2.0) (EXPT 20.8125 2.0))) 2.0) (- 63.0 0.625) 0)

Command: !point2
((/ (SQRT (+ (EXPT 20.8125 2.0) (EXPT 20.8125 2.0))) 2.0) (- 63.0 0.625) 0)

I gather that the ‘ acts like the AutoLISP function quote
 in that it acts as a literal , or prvents the statement following  evaluation ;
 this is sometimes what we need .
 Otherwise use the

  1. (setq point2 (list (/ (sqrt(+ (expt 20.8125 2.0) (expt 20.8125 2.0))) 2.0) ( 63.0 0.625) 0))

(see below)

Just got back from Lee Mac’s amazing site, and the explanation for use of the apostrophe and the quote function is described in depth.

http://www.lee-mac.com/quote.html

Thanks again, Lee Mac!

Learning is fun ctional .

« Last Edit: September 13, 2016, 01:12:07 AM by +X^N »


Logged


Страницы 1 2 Далее

Чтобы отправить ответ, вы должны войти или зарегистрироваться

RSS

Сообщения с 1 по 25 из 27

#1 26 мая 2004г. 20:11:45

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Тема: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Можно ли сделать сплошную заливку заданным цветом контура, ограниченного замкнутой полилинией?
Спасибо
Александр

#2 Ответ от VK 26 мая 2004г. 21:05:46

  • VK
  • Восстановленный участник
  • На форуме с 17 марта 2003г.
  • Сообщений: 1,980
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Штриховка типа «Solid»

#3 Ответ от Александр Р 26 мая 2004г. 21:31:21

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Спасибо, принцип понятен.
В этой связи возник следующий вопрос. Имеется множество полилиний, нарисованных несколькими цветами. Можно ли их все одновременно закрасить — каждую своим цветом?

#4 Ответ от VK 26 мая 2004г. 22:51:51

  • VK
  • Восстановленный участник
  • На форуме с 17 марта 2003г.
  • Сообщений: 1,980
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Некоторую группу полилиний можно закрасить одним… Но это будет одна штриховка на несколько полилиний.

#5 Ответ от nivas 27 мая 2004г. 10:35:50

  • nivas
  • Восстановленный участник
  • На форуме с 11 октября 2002г.
  • Сообщений: 139
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

угу, примерно так:
пишется lisp с алгоритмом: штрихуем все указанные объекты штриховкой типа solid для каждого объекта штриховка имеет цвет объекта
мне писАть лень :)

#6 Ответ от Александр Р 27 мая 2004г. 11:16:30

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Может быть, найдется кто-нибудь неленивый :). Сам я Лиспом не владею, поскольку Автокад лежит далеко вне сферы моей основной деятельности, но жизнь заставляет использовать его для проектирования фотошаблонов.
Как я понимаю, специалисту по ЛИСПу — это минут на пятнадцать работы, чтобы написать программу, реализующую алгоритм закраски.

#7 Ответ от Jura 27 мая 2004г. 12:46:45

  • Jura
  • Восстановленный участник
  • На форуме с 26 марта 2004г.
  • Сообщений: 608
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Фотошаблон!!!!!!!!!!!!!!
Так у полилиний есть ширина(width), и fill по умолчанию включен в On! Если фотошаблон надо только рисовать, т.е. если хвоста у программы нет, то просто управляйте изменением ширины полилинии. Правда с дырявыми «шинами» придется действительно штриховать, но их обычно меньше «по сравнению»…

#8 Ответ от Александр Р 27 мая 2004г. 13:01:21

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Спасибо за обсуждение.
Фотошаблоны у меня достаточно специфические и формируются автоматически во внешней САПР, откуда экспортируются в Автокад в формате DXF. толщиной полилиний здесь не обойдешься. Нужно либо разбираться с форматом DXF (как описать заштрихованный контур) и модифицировать программу экспорта контуров, либо писать программу закраски на АвтоЛИСП.

#9 Ответ от Jura 27 мая 2004г. 14:46:38

  • Jura
  • Восстановленный участник
  • На форуме с 26 марта 2004г.
  • Сообщений: 608
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Даа… погорячился sad
Если Lisp, то один из вариантов:
закладываться на вторую 330 группу (во всяком случае, если все boundary  одного цвета…)
и в entity из 330 смотреть цвет в 62 группе, и переставлять в 62 группу штриховки…
Но если делать пакетно, то в принципе круто…,
но штриховать, Вы скорее будете каждый контур индивидуально, или, если группу, то одного цвета (хотя IMHO групповуха может аукнуться). Тогда можно без лисба — штрихуете, потом используете кнопку «Match Properties»
(указываете эталлоную полилинию, затем объекты на котрые применить эталонное «оформление»)…
Или советы постороннего wink
Может поискать трассировщик с нормальным хвостом?
Во всяком случае проблема, наверняка уже решалась, может на специализированных сайтах пошарить, или на стеклах пошуровать?
PS  IMHO   заштриховать в автомате весь DXF  вряд ли реально… т.е. зависит от сложности конфигурации проводников…

#10 Ответ от spook 27 мая 2004г. 14:47:36

  • spook
  • Восстановленный участник
  • На форуме с 4 февраля 2004г.
  • Сообщений: 172
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Александр Р. пишет:

Как я понимаю, специалисту по ЛИСПу — это минут на пятнадцать работы, чтобы написать программу, реализующую алгоритм закраски.

Ну не 15 мин. — чуть дольше. smile В качестве варианта:

(defun c:filpl (/ sel doc space lays lay lname hat ch alay ach)
  (setq    doc   (vla-get-activedocument (vlax-get-acad-object))
    space (if (and (zerop (vla-get-activespace doc))
               (= :vlax-false (vla-get-mspace doc))
          ) ;_ end of and
        (vla-get-paperspace doc)
        (vla-get-modelspace doc)
          ) ;_ end of if
    lays  (vla-get-layers doc)
    sel   (vla-get-activeselectionset doc)
  ) ;_ end of setq
  (if (= (vla-get-lock (setq alay (vla-get-activelayer doc))) :vlax-true)
    (progn
      (vla-put-lock alay :vlax-false)
      (setq ach t)
    ) ;_ end of progn
  ) ;_ end of if
  (vla-clear sel)
  (vla-selectonscreen
    sel
    (vlax-safearray-fill (vlax-make-safearray vlax-vbinteger '(0 . 1)) '(0 70))
    (vlax-safearray-fill
      (vlax-make-safearray vlax-vbvariant '(0 . 1))
      '("LWPOLYLINE" 1)
    ) ;_ end of vlax-safearray-fill
  ) ;_ end of vla-SelectOnScreen
  (if (not (zerop (vla-get-count sel)))
    (vlax-for x    sel
      (if (= (vla-get-lock (setq lay (vla-item lays (setq lname (vla-get-layer x)))))
         :vlax-true
      ) ;_ end of =
    (progn
      (vla-put-lock lay :vlax-false)
      (setq ch t)
    ) ;_ end of progn
    (setq ch nil)
      ) ;_ end of if
      (setq hat (pl:mk-solidhatch x space))
      (vla-put-color hat (vla-get-color x))
      (vla-put-layer hat lname)
      (if ch
    (vla-put-lock lay :vlax-true)
      ) ;_ end of if
    ) ;_ end of vlax-for
  ) ;_ end of if
  (if ach
    (vla-put-lock alay :vlax-true)
  ) ;_ end of if
  (princ)
) ;_ end of defun
(defun pl:mk-solidhatch    (obj space / hat)
  (vla-appendouterloop
    (setq hat (vla-addhatch space achatchpatterntypepredefined "SOLID" :vlax-true))
    (vlax-safearray-fill (vlax-make-safearray vlax-vbobject (cons 0 0)) (list obj))
  ) ;_ end of vla-AppendOuterLoop
  hat
) ;_ end of defun

Вызов: filpl
Заливки помещаются на слой, в котором находится контур и им присваивается цвет, как у контура.

#11 Ответ от Александр Р 27 мая 2004г. 15:11:56

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Большое спасибо, SPOOK.
Правда, мне пока чуть рано радоваться:
при загрузке Вашей программы filpl получаю сообщение об ошибке:
error: bad argument type: numberp: nil
Как можно это исправить?

#12 Ответ от spook 27 мая 2004г. 15:22:29

  • spook
  • Восстановленный участник
  • На форуме с 4 февраля 2004г.
  • Сообщений: 172
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

> Александр Р.
Попробуйте перед загрузкой filpl запустить (vl-load-com). Версия ACAD’а должна быть не ниже R15.

#13 Ответ от Александр Р 27 мая 2004г. 15:36:42

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

К сожалению, не помогает, выдается сообщение
Unknown command «VL-LOAD-COM».
У меня АВТОКАД 2002. Можно ли переделать под него?

#14 Ответ от Александр Р 27 мая 2004г. 15:39:30

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Набрал (vl-load-com) вместе со скобками. Команда прошла, но ошибка в filpl осталась.

#15 Ответ от VK 27 мая 2004г. 16:00:04

  • VK
  • Восстановленный участник
  • На форуме с 17 марта 2003г.
  • Сообщений: 1,980
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

error: bad argument type: numberp: nil

Это ошибка несоответствия типа данных. Придется проверять по шагам, где она возникает. Вполне возможно, что в тестовом файле ее и не было.

#16 Ответ от spook 27 мая 2004г. 16:07:12

  • spook
  • Восстановленный участник
  • На форуме с 4 февраля 2004г.
  • Сообщений: 172
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Александр Р. пишет:

У меня АВТОКАД 2002. Можно ли переделать под него?

2002 = R15
Специально взял с форума через буфер, проверил в 2002-ом — всё работает.

#17 Ответ от Александр Р 27 мая 2004г. 16:42:47

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Спасибо, SPOOK и VK.
С вашей помощью запустил. Каюсь, виноват сам — скопировал в первый раз в буфер без первого символа (открывающей скобки перед defun), зрение уже не то :). Кроме того, все равно нужно перед выполнением выполнять
(vl-load-com) .
В связи с этим несколько вопросов:
1) нельзя ли каким-то образом засунуть (vl-load-com) в саму программу filpl или как-то грузить его автоматически при загрузке Автокада
2) можно ли автоматически загружать нужные приложения на ЛИСП при загрузке Автокада или это можно делать только через меню
3) большая просьба к SPOOK: не могли бы Вы по горячим следам сделать на базе этой программы обратную операцию:
убирать заливку с выделенных контуров. В практической работе мне нужно располагать обеими опциями, манипулируя в ими в зависимости от конкретной ситуации.
Заранее благодарен
Александр

#18 Ответ от VK 27 мая 2004г. 17:00:44

  • VK
  • Восстановленный участник
  • На форуме с 17 марта 2003г.
  • Сообщений: 1,980
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

1) нельзя ли каким-то образом засунуть (vl-load-com) в саму программу filpl или как-то грузить его автоматически при загрузке Автокад

Допиши ее хоть самой первой, хоть самой последней строкой.

2) можно ли автоматически загружать нужные приложения на ЛИСП при загрузке Автокада или это можно делать только через меню

APPLOAD -> STARTUP укажи этот Лисп-файл (впрочем, существуют и другие способы).

#19 Ответ от Александр Р 27 мая 2004г. 17:12:50

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Спасибо, VK.
Реализовал обе опции без проблем.
Для полного счастья не хватает только обратной операции (убирать заливку с контуров) — вот она, неблагодарная человеческая натура :).

#20 Ответ от spook 27 мая 2004г. 19:31:57

  • spook
  • Восстановленный участник
  • На форуме с 4 февраля 2004г.
  • Сообщений: 172
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

> Александр Р.

(defun c:filplre (/ sel doc lays lay lname hat ch ent330 eget)
  (setq    doc  (vla-get-activedocument (vlax-get-acad-object))
    lays (vla-get-layers doc)
    sel  (vla-get-activeselectionset doc)
  ) ;_ end of setq
  (vla-clear sel)
  (vla-selectonscreen
    sel
    (vlax-safearray-fill (vlax-make-safearray vlax-vbinteger '(0 . 1)) '(0 70))
    (vlax-safearray-fill
      (vlax-make-safearray vlax-vbvariant '(0 . 1))
      '("LWPOLYLINE" 1)
    ) ;_ end of vlax-safearray-fill
  ) ;_ end of vla-SelectOnScreen
  (if (not (zerop (vla-get-count sel)))
    (vlax-for x    sel
      (if
    (and (setq ent330 (assoc 330 (entget (vlax-vla-object->ename x))))
         (= "HATCH" (cdr (assoc 0 (setq eget (entget (setq ent330 (cdr ent330)))))))
         (= "SOLID" (cdr (assoc 2 eget)))
    ) ;_ end of and
     (progn
       (if (= (vla-get-lock (setq lay (vla-item lays (setq lname (vla-get-layer x)))))
          :vlax-true
           ) ;_ end of =
         (progn
           (vla-put-lock lay :vlax-false)
           (setq ch t)
         ) ;_ end of progn
         (setq ch nil)
       ) ;_ end of if
       (entdel ent330)
       (if ch
         (vla-put-lock lay :vlax-true)
       ) ;_ end of if
     ) ;_ end of progn
      ) ;_ end of if
    ) ;_ end of vlax-for
  ) ;_ end of if
  (princ)
) ;_ end of defun
(defun c:filre (/ sel doc lays lay lname hat ch dellst)
  (setq    doc  (vla-get-activedocument (vlax-get-acad-object))
    lays (vla-get-layers doc)
    sel  (vla-get-activeselectionset doc)
  ) ;_ end of setq
  (vla-clear sel)
  (vla-selectonscreen
    sel
    (vlax-safearray-fill (vlax-make-safearray vlax-vbinteger '(0 . 1)) '(0 2))
    (vlax-safearray-fill
      (vlax-make-safearray vlax-vbvariant '(0 . 1))
      '("HATCH" "SOLID")
    ) ;_ end of vlax-safearray-fill
  ) ;_ end of vla-SelectOnScreen
  (if (not (zerop (vla-get-count sel)))
    (progn
      (vlax-for    x sel
    (setq dellst (cons x dellst))
      ) ;_ end of vlax-for
      (foreach a dellst
    (if (= (vla-get-lock (setq lay (vla-item lays (setq lname (vla-get-layer a)))))
           :vlax-true
        ) ;_ end of =
      (progn
        (vla-put-lock lay :vlax-false)
        (setq ch t)
      ) ;_ end of progn
      (setq ch nil)
    ) ;_ end of if
    (vla-Delete a)
    (if ch
      (vla-put-lock lay :vlax-true)
    ) ;_ end of if
      ) ;_ end of foreach
    ) ;_ end of progn
  ) ;_ end of if
  (princ)
) ;_ end of defun

filplre — удаляет только ассоциативные штриховки типа солид от выбранных примитивов
filre — удаляет любые выбрвнные штриховки типа солид
Это в самом простом варианте. Можно, конечно, накрутить большее число проверок «на соответствие», но, вполне возможно, что и ни к чему.
Предупреждение: Код нормально не тестировался — могут быть ошибки.

#21 Ответ от Александр Р 27 мая 2004г. 20:01:33

  • Александр Р
  • Восстановленный участник
  • На форуме с 10 мая 2004г.
  • Сообщений: 18
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Большое спасибо, SPOOK!
Проверил обе утилиты на своем реальном примере из 3400 полилиний — все работает как нужно.
Надеюсь, что это наглядный пример для скептиков, которые  здесь на форуме сомневаются, нужно ли реально программирование на LISP для работы в Автокаде.
Еще раз большое спасибо всем, участвовавшим в обсуждении, и, в особенности, Вам, SPOOK, не пожалевшему своего времени для этой задачи.
Вопрос исчерпан, тема закрыта.

#22 Ответ от nivas 28 мая 2004г. 09:53:54

  • nivas
  • Восстановленный участник
  • На форуме с 11 октября 2002г.
  • Сообщений: 139
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

Надеюсь, что это наглядный пример для скептиков, которые здесь на форуме сомневаются, нужно ли реально программирование на LISP для работы в Автокаде.

офигенная фраза для конференции «Программирование: LISP» :D

#23 Ответ от ALEXANDR 2 июня 2004г. 10:51:30

  • ALEXANDR
  • Восстановленный участник
  • На форуме с 21 апреля 2004г.
  • Сообщений: 7
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

А если усложнить задачу и заполнить контур условными знаками (блоками) через какой-то интервал и в шахматном порядке? Заранее благодарен.

#24 Ответ от spook 2 июня 2004г. 11:29:06

  • spook
  • Восстановленный участник
  • На форуме с 4 февраля 2004г.
  • Сообщений: 172
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

> ALEXANDR
Заполнение, как таковое, сделать возможно, хотя и с некоторыми заморочками. Проблема возникнет с маскированием по краям. Единственный вариант с приемлемыми трудозатратами это создать собственную штриховку с нужным «орнаментом». Тогда, достаточно будет заменить «SOLID» на имя этой штриховки и позаботиться о её загрузке в файл рисунка.

#25 Ответ от VK 2 июня 2004г. 17:23:36

  • VK
  • Восстановленный участник
  • На форуме с 17 марта 2003г.
  • Сообщений: 1,980
  • Спасибо: 0

Re: Как сделать сплошную заливку контура, ограниченного замкнутой полилинией?

> ALEXANDR

> spook
А если обратить внимание на команду SUPERHATCH из Экспрессов? Или сделать нечто на ее основе….

Страницы 1 2 Далее

Чтобы отправить ответ, вы должны войти или зарегистрироваться

  1. 2014-12-09, 04:27 PM


    #1

    pogorilyi.oleg684953 is offline


    Woo! Hoo! my 1st post


    Post Error: bad argument type: numberp: nil

    Quote Originally Posted by dial.lsp

    Code:

    (defun c:star()  (setq dir "D:\CHEMERIS\Pog\")
      ;(setq dir "e:\Kolesov\")
    
    
    
    
      (data)
      (dial)
      (if (= st_dl 2)
        (progn
          (load (strcat dir "autolisp_val.lsp"))
          (c:autolisp_VAL)
      ))
      (if (= st_dl 2) (Vinoski))
      
      (if (= st_dl 3) (3d))
    
    
      (princ)
    ) 
    ;---------------------------------------------------
    (defun dial()
      (setq rf (load_dialog (strcat dir "Dial_0.dcl")))
      (new_dialog "dial_pr" rf)
    
    
      ; ×òåíèå èç ôàéëà
      (if (findfile (strcat dir "Dan.txt")) (load (strcat dir "Dan.txt")))
    
    
      ; Âûçîâ ñëàéäà
      (setq xmax (dimx_tile "RIS") ymax (dimy_tile "RIS"))
      (start_image "RIS")
        (slide_image 0 0 xmax ymax (strcat dir "slide.sld"))
      (end_image)
    
    
      
      ; Óñòàíîâêà çíà÷åíèé
    
    
      (foreach n nab_isx   (set_tile n (rtos (eval (read n)) 2 2)) ) 
    
    
    
    
       ; Áëîêèðîâêà êëàâø
      (gas_ok 1)
    
    
    
    
      
      ; Ââîä ìàñøòàáîâ
      (setq nab_mas '("M1:1" "M1:2" "M1:2.5" "M1:5" "M1:10" "M1:15" "M1:20"))
      (setq nab_masch '(1.0   0.5     0.4     0.2    0.1   0.06667   0.05))
      (start_list "MS")    (mapcar 'add_list nab_mas)  (end_list)
      (setq masch (nth 0 nab_masch)) (set_tile "MS" "0")
    
    
    
    
      ; Âûïîëíåíèå ïðèâõîäå â ïîëå
      (foreach n nab_isx  (action_tile n (strcat "(setq " n " (atof $value))") ))
    
    
      
      (action_tile "MS" "(setq masch (nth (atoi $value) nab_masch)) ")
      (action_tile "DEFAULT" "(progn (data)(foreach n nab_isx (set_tile n (rtos (eval (read n)) 2 2)) ))")
      (action_tile "PROV" "(prov_vv)")
      (action_tile "3D" "(done_dialog 3)")
      (action_tile "accept" "(done_dialog 2)")
      (action_tile "cancel" "(done_dialog 0)")
    
    
      (setq st_dl (start_dialog))
    
    
      (if (> st_dl 0)
        (progn
    
    
    
    
       ; Çàïèñü â ôàéë
          (setq f (open (strcat dir "Dan.txt") "w"))
             (princ "(setq n" f)
             (foreach n nab_isx
           (princ (strcat "   " n " " (rtos (eval (read n))) "n" ) f)
         )
             (princ ") n" f)
          (close f)
    
    
    
    
        ; Îïðåäåëåíèå ôàéëîâ ñ ó÷åòîì ìàñøòàáà
          (if (= st_dl 3) (setq masch 1.0))
          (maschtab masch)
    
    
      ))
    
    
    )
      
    ; -------------------------------------------------
    (defun data()
     ; Ââîä èñõîäíûõ äàííûõ
     (setq nab_isx '("_M24" "_L1" "_L2" "_L3" "_L4" "_L5" "_L43" "_L53" "_D1" "_D2" "_D3" "_D4"  "_D5" "_L" "_SR" "_A1" "_A2" "_Q" "_R1" "_R2" "_L0" "_SO"))
    (setq nab_rab '("M24" "L1" "L2" "L3" "L4" "L5" "L43" "L53" "D1" "D2" "D3" "D4" "D5" "L"  "SR" "A1" "A2" "Q" "R1" "R2" "L0" "SO"))
    (setq nab_dan '(10.0 160.0 267.0 440.0 400.0  130.0 267.0 160.0 260.0 300.0 310.0 330.0 20.0 165.0 133.0 5.0 3.0 4.0 7.0 5.0 2000.0 10.0))
    (setq masch 1.0)
    (mapcar '(lambda (isx dan)
           (set (read isx) dan)
          )
         nab_isx
         nab_dan
      )
      )
    
    
    
    
    ;--------------------------------------
    (defun gas_ok($k)
      (mode_tile "3D" $k) (mode_tile "accept" $k)
    )
    
    
    ;--------------------------------------------------------------------
    
    
    ;--------------------------------------------------------------------
    (defun prov_vv()
    ; Ïðîâåðêà ââîäà
      (setq prov 0)
      (if (> _D1 _D2)(alert (strcat "çíà÷åíèå _D1<"(rtos _d1)">  Äîëæíî áûòü ìåíüøå ÷åì _D2<"(rtos _d2)">")))
      (if (> _D1 _D2)(setq prov (+ 1 prov)))
      (if (> _D2 _D3)(alert (strcat "çíà÷åíèå _D2<"(rtos _d2)">  Äîëæíî áûòü ìåíüøå ÷åì _D3<"(rtos _d3)">")))
      (if (> _D2 _D3)(setq prov (+ 1 prov)))
           (if (> _D3 _D4)(alert (strcat "çíà÷åíèå _D3<"(rtos _d2)">  Äîëæíî áûòü ìåíüøå ÷åì _D4<"(rtos _d4)">")))
      (if (> _D3 _D4)(setq prov (+ 1 prov)))
       (if (< _D4 _D5)(alert (strcat "çíà÷åíèå _D4<"(rtos _d4)">  Äîëæíî áûòü áîëüøå ÷åì _D5<"(rtos _d5)">")))
      (if (< _D4 _D5)(setq prov (+ 1 prov)))
    
    
      (if (> _L1 _L2)(alert (strcat "çíà÷åíèå _L1<"(rtos _L1)">  Äîëæíî áûòü ìåíüøå ÷åì L2<"(rtos _L2)">")))
      (if (> _L1 _L2)(setq prov (+ 1 prov)))
        (if (< _L1 160.0)(alert (strcat "çíà÷åíèå _L1<"(rtos _L1)">  Äîëæíî áûòü áîëüøå ÷åì 160.0<"(rtos 160.0)">")))
      (if (< _L1 160.0)(setq prov (+ 1 prov)))
      (if (> _L2 _L3)(alert (strcat "çíà÷åíèå _L2<"(rtos _L2)">  Äîëæíî áûòü ìåíüøå ÷åì _L3<"(rtos _L3)">")))
      (if (> _L2 _L3)(setq prov (+ 1 prov)))
      (if (< _L3 _L4)(alert (strcat "çíà÷åíèå _L3<"(rtos _L3)">  Äîëæíî áûòü áîëüøå ÷åì _L4<"(rtos _L4)">")))
      (if (< _L3 _L4)(setq prov (+ 1 prov)))
        (if (< _A1 _A2)(alert (strcat "çíà÷åíèå _A1<"(rtos _A1)">  Äîëæíî áûòü áîëüøå ÷åì _A2<"(rtos _A2)">")))
      (if (< _A1 _A2)(setq prov (+ 1 prov)))
      (if (> _A1 25.0)(alert (strcat "çíà÷åíèå _A1<"(rtos _A1)">  Äîëæíî áûòü ìåíüøå ÷åì 25.0<"(rtos 25.0)">")))
      (if (> _A1 25.0)(setq prov (+ 1 prov)))
      
     ;
       
    
    
      (if (= prov 0)
        (progn
          (alert  "Â èñõîäíûõ äàííûõ îøèáîê íå îáíàðóæåííî")
          (gas_ok 0)
       ))   
      
    )
    ;--------------------------------
    (defun maschtab ($ms)
          (mapcar '(lambda (rab isx)
           (set (read rab) (* (eval (read isx)) $ms))
          )
        nab_rab
        nab_isx
          )
    
    
      )
    ;--------------------------------------------------------
    (defun Vinoski ()
    
    
    ;   (setq rf (load_dialog "E:\Stud\LS-81\Vinoski.dcl"))
      (setq rf (load_dialog (strcat dir "Dial_0.dcl")))
      
     ; Óñòàíîâêà toggle
       (setq VIN1 1) (set_tile "VIN1" (itoa VIN1))
       (setq VIN2 1) (set_tile "VIN2" (itoa VIN2))
       (setq VIN3 1) (set_tile "VIN3" (itoa VIN3))
    ;;;   (setq VIN4 0) (set_tile "VIN4" (itoa VIN4))
    
    
      ; Ââoä ìàñøòàáîâ
      (setq nab_mas '("M5:1" "M4:1" "M2:1" "M1:1" "M1:2" "M1:2.5" "M1:5" "M1:10" "M1:15" "M1:20"))
      (setq nab_masch '(5.0   4.0   2.0    1.0     0.5     0.4     0.2    0.1    0.06667   0.05))
    
    
      (start_list "MS1")  (mapcar 'add_list nab_mas)  (end_list)
      (setq ms1 (nth 4 nab_masch)) (set_tile "MS1" "4")
    
    
      (start_list "MS2")  (mapcar 'add_list nab_mas)  (end_list)
      (setq ms2 (nth 7 nab_masch)) (set_tile "MS2" "7")
    
    
      (start_list "MS3")  (mapcar 'add_list nab_mas)  (end_list)
      (setq ms3 (nth 7 nab_masch)) (set_tile "MS3" "7")
        
     ; (action_tile "MS1" "(setq ms1 (nth (atoi $value) nab_masch)) ")
     ; (action_tile "MS2" "(setq ms2 (nth (atoi $value) nab_masch)) ")
      ;(action_tile "MS3" "(setq ms3 (nth (atoi $value) nab_masch)) ")
    )
    
    
    (defun 3d()
    
    
      
      (command "_ERASE" "_ALL" "")
      (setvar "OSMODE" 0) ; îòêëþ÷èòü ïðèâçÿêè
      (command "_shademode" "_2")
    
    
      (if (null autolisp_kolesov_VAL_DETAL)  (load (strcat dir "autolisp_VAL.lsp")))
      (load "ramka")
      (setq bp '(0 0 0))
      (setq hline 0)
      
      (opred_point)
    
    
      ; ×åðòåæ äåòàëè
    (command "_pline" p1 p2 p3 p4 p5 p6 p7 "_a" "_a" 90 p8 "_l" p9 p10 p11 p12 p13 "_a" "_a" 90 p14 "_l" p15 p16 p17 p18 p19 p20 "_c")
       (command "_revolve" (entlast) "" BP (polar BP 0 1) "")
        (setq obj3 (entlast))
       (command "_circle" KP2 d5)
        (setq obj4 (entlast))
        (command "_move" obj4 "" (list 0 0 0) (list 0 0 (+ (/ d3 2) r1)) "")
       (command "_circle" KP3 d5)
        (setq obj5 (entlast))
        (command "_move" obj5 "" (list 0 0 0) (list 0 0 (+ (/ d3 2) r1)) "")
         (command "_circle" KP4 d5)
        (setq obj6 (entlast))
        (command "_move" obj6 "" (list 0 0 0) (list 0 0 (+ (/ d3 2) r1)) "")
         (command "_circle" KP5 d5)
        (setq obj7 (entlast))
        (command "_move" obj7 "" (list 0 0 0) (list 0 0 (+ (/ d3 2) r1)) "")
      (command "_pline" KP6 KP7 KP8 KP9 "_c")
          (setq obj8 (entlast))
        (command "_move" obj8 "" (list 0 0 0) (list 0 0 (+ (/ d3 2) r1)) "")
        (command "_pline" KP10 KP11 KP12 KP13 "_c")
          (setq obj9 (entlast))
        (command "_move" obj9 "" (list 0 0 0) (list 0 0 (+ (/ d3 2) r1)) "")
        (command "_extrude" obj4 obj5 obj6 obj7 obj8 obj9 "" (- 100) 0)
        (setq obj10 (entlast))
      (setq kont (ssadd))
    
    
      (while obj4
        (ssadd obj4 kont)
        (setq obj4 (entnext obj4)))
    
    
      (command "_subtract" obj3 "" kont "")
      
     
      (command "_pline" OSI OSI2 "")
       (setq obj17 (entlast))
      (command "_pline" OSI OTV OTV3 OTV4 OTV5 OTV6 "_c")
       (setq obj18 (entlast))
       (command "_revolve" obj18 "" "_o" obj17 "")
       (setq obj19 (entlast))
      (command "_ucs" "_g" "_f")
     (command "_copy" obj19 "" BP1 (polar QQ1 0 62.5))
       (setq obj20 (entlast))
    (command "_copy" obj19 "" BP1 (polar QQ1 PI 62.5))
       (setq obj21 (entlast))
        (command "_-view" "_o" "_l")
      (command "_ucs" "_g" "_l")
      (command "_mirror" obj19 obj20 obj21 "" MIR MIR1 "")
         (setq obj22 (entlast))
       (setq kont3 (ssadd))
    
    
      (while obj19
        (ssadd obj19 kont3)
       (setq obj19 (entnext obj19)))
         (command "_subtract" obj3 "" kont3 "")
        (command "_subtract" obj3 "" obj22 "")
      
    )

    Error: bad argument type: numberp: nil.

    When Try use 2D or load autolisp_val


Понравилась статья? Поделить с друзьями:
  • Error authserver i o error connection refused no further information
  • Error authorization failed incorrect rpcuser or rpcpassword
  • Error authorization error receive bytes failed
  • Error authentication rejected unspecified
  • Error authentication failed ugfzc3dvcmq6