Jump to content

Recommended Posts

Posted

I have just had a problem joining simple arcs and lines to a polyline!!!

B.dxf is an example.

Using Join produces SPLINE, not POLYLINE.

 

What fixed the problem was opening the file in RHINOCEROS, exporting all the geometry to a new DXF and changing the export setting to Flip Arc Normals To Z+

After that Join in autocad works as it should. See the file B2.dxf

 

That is telling me that Z normals of the arc written as Z- in the input dxf giving us a lot of trouble in Autocad files.

 

The question is... Is there a way to flip the negative arc normal in affected autocad DWG in any way? Using LISP perhaps?

 

b.dxf b2.dxf

Posted

1st suggestion get a copy of text2geom by Seant. It explodes text and makes dwg objects a great product.

 

There are 2 versions a Acad version and a Bricscad Version. Just google "STSC_Text2Geom Autocad" I think its up to ver 21. Trying to find most recent update.

 

Posted (edited)
On 8/14/2024 at 7:19 PM, BIGAL said:

1st suggestion get a copy of text2geom by Seant. It explodes text and makes dwg objects a great product.

 

There are 2 versions a Acad version and a Bricscad Version. Just google "STSC_Text2Geom Autocad" I think its up to ver 21. Trying to find most recent update.

 

 

That sure works for the purpose, but there are tons of files with circles like that from rhino entering cad files... i need general solution to flip the circles.

The font was only easiest way to reproduce the behavior.

This is an unanswered question in many forums for no one assumed the cause well. I did, comes from Rhino (or other software) exports of circle to dxf with -Z coordinate. That destroys the geometry for autocad, even the flatten command cannot solve. Very few people working in CAD has Rhino too and this problem does spread by simple copy - paste.

Text2Geom is a lovely lisp, but does not solve the problem at all. The problem is not only font related, it is about circles with Z- normals that cannot be processed in autocad.

Flipping the circles with Z- to Z+ is the solution.

Lisp to do that, that is,

because the cause could be any other software too and not font related at all.

The lisp looking for circles with Z- normal and flipping it to Z+ is the only universal solution working in Autocad directly addressing the issue.

 

i did find a post with the following code :

 

(foreach ent
  (mapcar 'cadr (ssnamex (ssget "_X" '((0 . "CIRCLE,ARC") (210 0.0 0.0 -1.0)))))
  (command
    "_.ucs" "_zaxis"
      (trans (cdr (assoc 10 (entget ent))) ent 0); origin
      (vlax-curve-getPointAtDist ; Z-direction point [midpoint]
        ent
        (/
          (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
          2
        ); /
      ); ...getPoint... and UCS
    "_.rotate" ent "" "0,0" "180"
    "_.ucs" "_previous"
  ); command
); foreach

 

 

This one works well too...:

 

(defun c:fliparcs3 (/ ss hpi en el)
  (setq
    ss (ssget "X" (list (cons 0 "ARC") (cons 210 '( 0 0 -1))))
    hpi (* 0.5 pi)
  )
  (cond
    (
      (not (null ss))
      (repeat (sslength ss)
        (ssdel (setq en (ssname ss 0)) ss)
        (setq el (entget en))
        (entmod
          (mapcar
            (function
              (lambda (x / g)
                (setq g (car x))
                (cond
                  ((= g 10) (cons 10 (mapcar '* (list -1.0 1.0 -1.0) (cdr x))))
                  ((= g 210) (cons 210 (mapcar '- (cdr x))))
                  ((= g 50) (cons 50 (+ hpi (- hpi (cdr (assoc 51 el))))))
                  ((= g 51) (cons 51 (+ hpi (- hpi (cdr (assoc 50 el))))))
                  (t x)
                )
              )
            )
            el
          )
        )
      )
      (princ "\nDone")
    )
    (t (princ "\nNothing selected"))
  )
  (princ)

 

 

 

 

That does the job for all circles with Z-

I'd love to be able to do that with a selection of arcs too.

 

Leemac once wrote :

 

(defun c:test ( / c i n s x )

    (if (setq s (ssget "_X" '((0 . "CIRCLE") (210 0.0 0.0 -1.0))))

        (repeat (setq i (sslength s))

            (setq i (1- i)

                  x (entget (ssname s i))

                  n (assoc 210 x)

                  c (assoc 010 x)

            )

            (entmod (subst (cons 10 (trans (cdr c) (cdr n) 0)) c (subst '(210 0.0 0.0 1.0) n x)))

        )

    )

    (princ)

)

 

I was not able to use this one, but looks elegant.

 

 

Edited by ibach
Posted

See if this works, not tested since I am at home and I'm not all that good at LISP. Just a lot of internet searching, LeeMac, AfraLISP among other places.

 

;;; Flip arcs and circles from the -Z plane to the +Z plane.                                                          *|
;;;                                                                                                                   *|
;;; https://www.cadtutor.net/forum/topic/89687-autocad-join-comand-converts-arc-and-lines-to-splines-instead-polyline *|
;;;                                                                                                                   *|
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*|

(defun c:FlipArcsCircles (/ ss ent obj pt1 pt2 newCenter)
  (setq ss (ssget '((0 . "ARC,CIRCLE")))) ; Select arcs and circles
  (if ss
    (progn
      (setq cnt (sslength ss))
      (setq i 0)
      (while (< i cnt)
	(setq ent (ssname ss i))
	(setq obj (vlax-ename->vla-object ent))
	(setq pt1 (vlax-get obj 'Center))

	(setq newCenter (list (car pt1) (cadr pt1) (* -1 (caddr pt1))))

	(vlax-put obj 'Center newCenter)
	(setq i (1+ i))
      )
      (princ (strcat "\nFlipped " (itoa cnt) " objects."))
    )
    (princ "\nNo arcs or circles selected.")
  )
  (princ)
)


 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...