Jump to content

Redraw polylines


ahyin

Recommended Posts

(defun c:redrawpl ()
(setq sset (ssget "x" '(0 . "lwpolyline") (cons 67 (logand (1+ (getvar "TILEMODE"))1)) ))
   (setq ctr 0)
   (repeat (sslength sset)
    (setq item (ssname sset ctr))
      (vl-cmdf "_isolateobjects" item "")
       (setq ron (vlax-ename->vla-object item))
         (setq olayer (vla-get-layer ron))
         (command "-layer" "set" olayer "" )
         (setq p1 (pline-centroid item))
         (vl-cmdf "_.-boundary" "_A" "_O" "polyline" "_I" "_N" ""  p1 "")
        (vl-cmdf "_unisolateobjects" "")
        (vla-delete ron)
         (command "_change" (entlast) "" "p" "la" "layer1" "")
        (setq ctr (1+ ctr))
   )
)

 

I'm trying to redraw all polylines by above method. To avoid create incorrect polyline, I'm using the function of isolateobjects to switch off others objects. Then it will based on the remain polyline to create the new one. But I found when I use this method apply on drawing which is many objects inside is quite slowly. In addition, some polylines unable to create by this method. Is there any others good method to create the polylines ?

 

Thank you !

Link to comment
Share on other sites

Please take a look on ENTMAKE function as an alternative solution.

 

Or, may try to disable OSMODE system variable instead of isolate the entity - don't forget to restore it later.

 

(setq PrevOsnapMode (getvar "OSMODE"))   ;retain current state
(setvar "OSMODE" 0)                      ;disable auto OSNAP
[color=blue]; your procesing here[/color]
(setvar "OSMODE" PrevOsnapMode)          ;restore previous state

 

Regrads,

Mircea

Link to comment
Share on other sites

Thank you Mircea quick response ! Can you teach me how to write this testing condition.

 

(defun c:creg ()
(setq a (car (entsel)))  
(command "region" a "")
;[color=blue]if convert to region is failed then explode it and then rejoin by pedit
[/color] (while 
(setq ent (vlax-ename->vla-object a)) 
  (vla-explode ent)
    (command "_.pedit" "_m" 
 (ssget "_p") "" "_y" "_j" 0.0 "")
 
     )
)

Link to comment
Share on other sites

How about comparing the last available entity in drawing (before attempt to create the region) with the last one after the region command was issued? Those should be different if conversion to region was successful.

 

(setq LastItem (entlast))   ;retain last item in drawing

[color=green](setq a (car (entsel)))  [/color]
[color=green](command "_REGION" a "")[/color]    ;attempt to create a region

(setq DrawItem (entlast))   ;list again last item in drawing

(if (not (equal LastItem DrawItem))   ;compare above entities
(prompt "\The region was created!")
(prompt "\The region wasn't created!")
)

 

Regards,

Mircea

Link to comment
Share on other sites

Thank you Mircea, I'm trying to use this method to create the region but unsucessful.

 

(defun c:creg ()
 
(setq a (car (entsel)))  
(setq lastitem (entlast ))
(command "region" a "")
(setq drawitem (entlast))
(if (not (equal lastitem drawitem))
  (prompt "The region was created")
  (progn
  (setq ent (vlax-ename->vla-object a)) 
    (vla-explode ent)
     (command "_.pedit" "_m" 
  (ssget "_p") "" "_y" "_j" 0.0 "")
  )
  (command "region" (entlast))
   )
 )

Link to comment
Share on other sites

Try to parse by ENTNEXT the newly created entities (from explosion command) starting from the last entity in drawing prior explosion; create a new selection set with SSADD.

 

Regards,

Mircea

Link to comment
Share on other sites

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...