why does this code work in autocad and not in bricscad?

why does this code work in autocad and not in bricscad ?

(defun c:PCCC ( / cen rad oom)
(and
(setq oom (getvar "orthomode") )
(setvar "orthomode" 0)
(setq cen (getpoint "\nCENTER :") )
(setq rad (getdist cen "\nRADIUS :") )
(vl-cmdf "pline" (polar cen pi rad) "arc" "radius" rad "angle" 180 0.0 "close")
(vla-put-LinetypeGeneration (vlax-ename->vla-object (entlast) ) :vlax-True)
(setvar "orthomode" oom)
)
(princ)
)

Comments

  • aridzv
    edited April 11
    1. please use code tag when writing code.
    2. for me the lisp works - see attached screen recording.

  • NO

    IT DOESN'T WORK.

    the PCCC command should only

    draw a CIRCLE using a POLYLINE...

    check PCCC behavior in AUTOCAD ...

  • aridzv
    edited April 11

    nice.

    1.now you understand that you need to explain what a code you post and complain that it is not work should do. when you say it is not working it means it don't load or raise an error when running. the code works fine in bricscad - just isn't doing what you expect it to do.

    2. share screen rcording in acad.

    3. buy me a license for autocad and I'll check it for you…

  • beware of BricsCAD error messages!
    it doesn't work well anyway!

  • no error for me with your code - see attached screenshot,

    But maybe you came across the beginning of a code to build a spiral according to the Fibonacci ratio….

    😁😂🤣

  • aridzv
    edited April 11

    in your screenshot it say:

    error : automation error

    in my screenshot it is working - asking for Direction of chord and get it - 38.2942

    Direction of chord (hold CTRL to switch direction) <38.2942>:

    this is not an error.

    I don't see any errors but mybe you should create a support request (SR) with bricscad support about this.

  • aridzv
    edited April 11

    @domenicomariapisano@gmail.com

    see code that is working:

    (defun c:PCCC ( / cen rad oom)
    (and
    (setq oom (getvar "orthomode") )
    (setvar "orthomode" 0)
    (setq cen (getpoint "\nCENTER :")
    )
    (setq rad (getdist cen "\nRADIUS :") )
    (vl-cmdf "pline" (polar cen pi rad) "arc" "radius" rad "angle" 180 "" "close")
    (vla-put-LinetypeGeneration (vlax-ename->vla-object (entlast) ) :vlax-True)
    (setvar "orthomode" oom)
    )
    (princ)
    )

    I replaced the value for Direction of chord (hold CTRL to switch direction) <90>to "" which mean geting the default value:

    old line: (vl-cmdf "pline" (polar cen pi rad) "arc" "radius" rad "angle" 180 0.0 "close")

    new line: (vl-cmdf "pline" (polar cen pi rad) "arc" "radius" rad "angle" 180 "" "close")

    see attached screen recording as well.

    it will be nice to see how the old code works in autocad.

  • the center of the circle does not coincide with CEN ...

    but the question is another

    the question is the different behaviour of the PLINE between ACAD and BCAD …

    (in ACAD it draws a CIRCLE that has the center in CEN , and the radius equal to RAD)

    ...

    This is what I want to highlight and make known to those responsible for software development

  • I don't have autocad - so you have to atleast show screenrecording from acad to verify that it is working there.

  • aridzv
    edited April 11

    here is a lisp that work for drawing a circle and turn it polyline:

    (defun c:PCCC1 ( / cen rad oom)
    
    (setq oom (getvar "orthomode"))

    (setvar "orthomode" 0)

    (setq cen (getpoint "\nCENTER :"))

    (setq rad (getdist cen "\nRADIUS :"))

    (command "circle" cen rad)

    (command "_.pedit" (entlast) "y" "x")

    (vla-put-LinetypeGeneration (vlax-ename->vla-object (entlast) ) :vlax-True)

    (setvar "orthomode" oom)

    (princ)

    )

  • but I too, in a different way, have written a code that does this thing, in Bricscad ... as I already said, I just want to point out that the behavior of the polyline command is different between Acad and Bcad ... that's all ...

  • aridzv
    edited April 11

    and one with pline command:

    (defun c:PCCC2 ( / cen rad oom)
    (setq oom (getvar "orthomode") )
    (setvar "orthomode" 0)
    (setq cen (getpoint "\nCENTER :") )
    (setq rad (getdist cen "\nRADIUS :") )
    (vl-cmdf "pline" cen "A" "R" rad "A" 180 "" "CL")
    (vla-put-LinetypeGeneration (vlax-ename->vla-object (entlast) ) :vlax-True);; what linetype are you generating here?…
    (setvar "orthomode" oom)
    (princ)
    )

  • aridzv
    edited April 11
    1. you can allways send an SR.
    2. And I still haven't seen your original code work in autocad or anywhere else.

    Your "pline" command seems a bit messy:

    (vl-cmdf "pline" (polar cen pi rad) "arc" "radius" rad "angle" 180 0.0 "close")

    at first,pline command ask for start point (that will be the center if arc is selected later).

    you gave (polar cen pi rad)that make no sense .

    "polar" function return "the UCS 3D point at a specified angle and distance from a point",

    where pline expects a point that your code do create with the varaible "cen".

    after that (give correct point),up to the angle it is ok,

    but forcing the Direction of chord to 0.0 force the user to enter a value, and setting it to default by using "" (enter) in the code works.

    look,

    I don't have autocad,But I would be very surprised if your original code works there as well.

  • I just want to point out that the behavior of the polyline command is different between Acad and Bcad

  • "but I would be very surprised if your original code works there as well"

    I wrote this little routine for my employer who uses Acad.
    And to my surprise it doesn't work in Bricscad like it does in Acad.
    You don't believe it?
    Patience!

  • aridzv
    edited April 12

    Let's make it simple:

    1. in your original code the base point is POLAR meaning point from a point ,and you set the function parameters as the center point and radius that where set by the user, and the movment direction as 180deg (pi). the circle center point was EXACTLY there in the code I shared and you complained the center is wrong, so the center was correrct according to the POLAR function and this function behave exactly the same in both autocad and bricscad.
    2. about forcing the Direction of chord to 0.0 - I'll wait for an autocad user here in the forum to verify whether the two programs behave differently in this part of the pline function.

  • and I am absolutely sure that the same code has 2 different behaviors in ACAD and BCAD...

  • And there are some how are absolutely sure that the earth is flat...

    We can either wait for an autocad user to check it or you can send a support request to bricscad support.

  • but I too am convinced that the earth is flat!

  • aridzv
    edited April 12

    when using your original code witn Direction of chord set to 0,

    it get this message: "A value other than zero is needed. Please try again."

    that means that bricscad expect a number that it is not 0.

    if you sure this code with Direction of chord set to 0 run in autocad then you should post a SR to bricscad support.

  • aridzv
    edited April 12

    a workaround is to set the "ang" varaible in the polar function to 2*pi this way: (polar cen (* 2 pi) rad),

    and the Direction of chord to 180 in the pline command this way:

    (vl-cmdf "pline" (polar cen (* 2 pi) rad) "arc" "radius" rad "angle" 180 180 "close")

    again - if you sure that autocad accept 0 as the Direction of chord angle then submit SR.

  • Thanks to my employer who gave me access to his PC !

  • aridzv
    edited April 12

    excuting just (vl-cmdf "pline" (polar cen pi rad) "arc" "radius" rad "angle" 180) without setting the Direction of chord in the code and then setting in manually to 0 and hit CL to close the polyline (circle) works in bricscad as well - see screenshot.

    submit SR to bricscad reporting your issue.

    e.

  • Yes, looks like a bug in BricsCAD. Doesn't allow you to enter 0 deg for direction. Recommend you raise a support request.

    Here's an alternate method to draw a PLINE circle using a DONUT.

    (defun C:PCCC (/ cen dia)
    (acet-error-init '(("CMDECHO" 0 "ORTHOMODE" 0 "PLINEGEN" 1) 0 nil))
    (and
    (setq cen (getpoint "\nCENTER :"))
    (setq dia (* 2.0 (getdist cen "\nRADIUS :")))
    (vl-cmdf "._DONUT" dia dia "_non" cen "")
    )
    (acet-error-restore)
    )

    Jason Bourhill

    CAD Concepts Ltd
    cadconcepts.co.nz